javascript - PHP echoing emptying string in $.ajax response -
I am trying to retrieve data from an AJAX call. I have tested with a string but it is returning empty, I just want to console the response to the string.
JS:
makeRequest: function (sService, oData) {var request = $ .post ( '.. /../Utils/utils/php/userQuery. Php ', {' service ': sService,' oData ': oData},' json '); Request.done (function (oResult) {// This is to stop firing, but an empty string is printed console.log (JSON.stringify (oResult)); var fail = errorHandler.check (oResult); if (! Fail ) {It is firing off but empty string console.log (oResult);} else {console.log (unsuccessful);}}) is printing; Request.fail (function (oResult) {console.log ("There was an error retrieving service data");}); }
PHP: If I Answer: The updated code of the above work was a number of problems provided by the answer. I hope it helps someone else. In $ Trying ParseJSON (oResult)
, I get an error in parsing because it's empty where am I going?
- Server dev-tools in your browser to check the reaction. Maybe the reaction is actually empty?
- You want to get JSON data, but you do not output
json_encode
- PHP constructor 2 underscore:
__ construct
(not_construct
) -
$ sService = $ _POST [ 'service'];
should be$ this-> SService = $ _POST ['service'];
- When you
new request ();
Comments
Post a Comment