I am trying to do an ajax Call using jquery in one of my webpages.
It’s going into Error function all the time.
When I look at the console in Firebug, the status seems to be ok , it displays 200 OK.
And when I manually launch the url in a firefox window, i am getting the expected page.
But when the same url is being called through jquery ajax, it always goes into the error function.
Following are the various values that i got during debug
xhr.readyState=4
xhr.statusText=Error
xhr.responseBody=undefined.
Could anyone of you please help me with this ?
function ajax_call(urlString)
{
ret_val="";
$.ajax
(
{
type: "GET",
url: urlString,
async:false,
cache:false,
success: function(msg)
{
ret_val=msg;
},
error:function (xhr, textStatus, thrownError)
{
ret_val=xhr.readyState;
alert("textStatus=" +textStatus);
}
}
);
return ret_val;
}
It was my mistake !
In the browser URL , i was looking at
“http://localhost/data.php”
in the AJAX call , i was calling the same php by giving absolute url like
“http://xyz.com/data.php”
as a result, ajax call was considering this as a cross domain call, although it was for the same php.
Resolved this by calling the relative url
“/data.php”