Thanks you for sharing @duncanc
I am still getting the problem.
localhost: always return "FAIL" demo.phplist.org: always return nothing (empty response) [for crossOrigin true and false]
i changed the list to list[x] where x is a valid list-id. (3 for localhost and 5 for demo.phplist.org)
(also, i tried query argument id=x , x as above)
@duncanc thanks for clearifing the query argument “id” usage.
also, im using a local server for development. (and the same server also serve the ajax enable form you provided.)
so, i guess ACCESS_CONTROL_ALLOW_ORIGIN is out of the question (though i even tried define("ACCESS_CONTROL_ALLOW_ORIGIN", "*"); in config for testing)
still the localhost server return “FAIL” output. p=asubscribe&id=1 and request email=aaa%40aaa.com&attribute1=aaa&htmlemail=1&list%5B3%5D=signup&subscribe=subscribe&VerificationCodeX=
where my subscribe page id (default page) is 1
and list-id is 3
@duncancTHANK YOU VERY MUCH, finally the item appeared in the list.
you took the effort to clearify stuffs.
So, here is the deal for future readers.
Get @duncanc above script.
modify the <input> list[MY_LIST_ID] = "signup"
in the url query argument id change id=SUBSCRIBE_PAGE_ID where SUBSCRIBE_PAGE_ID is a newly created list page that offer single list with the above option (as @duncanc describe in the previous post)
and you should be running (or atleast near your goal that need more debugging ).
I’ve used the example above and my form works great. There is however no message to the user once he/she submit the form and they don’t know if it works.
Does the code below suppose to throw a message on success? If yes, it doesn’t.
It is working however the whole form fine.
Any idea how I can throw a success message on submit?
@duncanc thanks for posting your code. I was able to get it work after enabling ACCESS_CONTROL_ALLOW_ORIGIN.
The problem I have now is that the confimation is returning the complete thank you page and not displaying just the message defined in the code. It’s not even displaying the code set in the “Text to display when subscription with an AJAX request was successful” section of the subscribe page config.
I am very glad to have found this thread! I have tried to implement this type of ajax subscribe functionality on my own many times with various hacky homecooking methods not realizing that the functionality was built in!
However I am having the same FAIL results as other people who had difficulty with this at first.
For testing I am using the same (localhost) domain for the my phplist and the page serving the form so my ajax url is: url: '/lists/index.php?p=asubscribe&id=4', (subscribe page 4 is a subscribe page that defaults to html email and does not display email address confirmation field).
Just in case it would help I added define('ACCESS_CONTROL_ALLOW_ORIGIN', '*'); to /lists/config/config.php.
I changed the hidden list input to a list that I have have set up <input type="hidden" name="list" value="signup" />
Other then these changes I am using the code as supplied (generously!) by @duncanc
I am using, PhpList v3.3.1 and PHP v7.0.22
Inspecting the request with dev tools reveals the following: Query string p: asubscribe id: 4 Form data email: firstname.lastname@example.org attribute1: myname htmlemail: 1 list: signup subscribe: subscribe VerificationCodeX:
Response Payload FAIL
Is there any way to get more detail on what causes the FAIL response?