View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0019524||phpList 3 application||General||public||02-11-18 19:03||26-07-19 12:57|
|Priority||normal||Severity||minor||Reproducibility||have not tried|
|Target Version||3.3.6||Fixed in Version||3.3.6|
|Summary||0019524: return error code on FAIL in ajax subscribe|
|Description||This is apparently a long-standing issue with the community-recommended way for users to be able to add subscribers to phplist from an external domain using ajax in phplist3 as described in this thread:|
The code in the zip file attached to the above thread uses jquery's ajax function, and it defines a function success() that's triggered when the ajax call succeeds and a error() function that's triggered when the ajax call failed. The problem is: phplist merely prints "FAIL" in the response when the subscribe attempt fails, but the status code remains a 200.
IMHO, the ajax form should not have to search for the string "FAIL" in the response in order to detect a failure. Instead, it should check the status code of the HTTP response from the server. This can be achieved, for example, by throwing an exception in PHP--which will make PHP return a 500 Internal Server Error.
Here is the relevant code for handling ajax subscription queries on phplist's side:
My recommendation is to add the line:
throw new Exception( "Error: Subscribe attempt failed!" );
after the "echo 'FAIL';" line here:
|Tags||No tags attached.|