Ajax 200 response is ok but shows that it was not possible to load response data

I am making an ajax call for the backend rest api, api returns a fine. If I console.log () success data and error data, it gives a “registered resource”, 200 ok on the console, but when I look at it in the network tab response for this auth / login route, it shows “Failed to load response data " And this happens sometimes only and not always. What for? Here is a snippet of my ajax call.

ajax .post('auth/login', { data: { oauth_provider: 'google', oauth_token: (isToken ? authResult : authResult.access_token) }, cache: false }) .done(function(data) { console.log(data); // Resource Logged in }) .error(function(err){ console.log(err); }) 

Here is the contents of my ajax.js

 define( [ 'jquery', 'util', ], function ($, util) { var ajax = { request: function (type, url, options) { if (url.indexOf('http') === -1) { url = util.url(url); } if (options === undefined) { options = {}; } options.type = type options.url = url; return $.ajax(options); }, get: function (url, options) { return ajax.request('GET', url, options); }, post: function (url, options) { return ajax.request('POST', url, options); }, put: function (url, options) { return ajax.request('PUT', url, options); }, delete: function (url, options) { return ajax.request('DELETE', url, options); } }; return ajax; } ) 

enter image description here enter image description here

+10
source share
4 answers

Apparently, it turns out that there is a problem with clearing cookies. When cleaning them, the system behaves normally. Help is not necessary!

+3
source

I confirm this. Since the version of Chrome is 45 and I see that some of my Ajax requests got 200 as a status code, but there was a problem with the content displaying “Could not load content”.

My Ajax requests are inside a loop, requesting failed content so that the content loads normally.

It seems that the solution inside the for loop uses setTimeout between the request and the other.

+1
source

Due to postback, this was happening in my project. When I solved the postback problem, the error went away.

-1
source

All Articles