Muhammad Tahir
Muhammad Tahir

Reputation: 5184

Jquery ajax request error callback is called instead of success even after response recieved from server

I am using jQuery ajax function to get some content from my webservice. Response from the server is received but every time error callback is called instead of success callback.

And this error is returned in xhr.error:

function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}

Here is the screenshot of response from server:

error pic

and here is the code I am using to make the request:

function abcdef()
{
$.ajax({
    url: "http://192.168.61.129:8000/get-yt-access-token/",
type: "GET",
contentType:"application/json",
error: function(xhr, textStatus, errorThrown){
    alert("its error! " + xhr.error);
    },
success: function(data){
    alert(data);
    }
});
}

Upvotes: 0

Views: 1201

Answers (1)

Muhammad Tahir
Muhammad Tahir

Reputation: 5184

It was a CORS issue at the end! solved it! run both webservice and webpage from same server and problem was solved.

Upvotes: 1

Related Questions