You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Rest API does not always return a valid json response.
if the answer is empty, jQuery displays the following error: see #4207
SyntaxError: Unexpected end of JSON input
at parse ()
at ajaxConvert (jquery.js:8787)
at done (jquery.js:9255)
at XMLHttpRequest. (jquery.js:9548)
Before ds-improved-ajax it was possible to correct this error by modifying the dataType used by jQuery in the ajaxOptions method:
exportdefaultDS.RESTAdapter.extend({ajaxOptions: function(url,type,options){varhash=this._super(url,type,options);// override if it's a POST request (empty response)if(type=='POST'){hash.dataType='text';}returnhash;}}
What is the recommended solution for this since ajaxOptions is deprecated?
I did not see anything in the methods mentioned to modify the response:
methodForRequest to get the HTTP verb
urlForRequest to get the URL
headersForRequest to get the headers
dataForRequest to get the data (query params or request body)
The text was updated successfully, but these errors were encountered:
A Rest API does not always return a valid json response.
if the answer is empty, jQuery displays the following error: see #4207
Before ds-improved-ajax it was possible to correct this error by modifying the dataType used by jQuery in the ajaxOptions method:
What is the recommended solution for this since ajaxOptions is deprecated?
I did not see anything in the methods mentioned to modify the response:
methodForRequest
to get the HTTP verburlForRequest
to get the URLheadersForRequest
to get the headersdataForRequest
to get the data (query params or request body)The text was updated successfully, but these errors were encountered: