Reputation: 331
I know there are many such questions, i tried those answers but my problem is not solved.
Am sending string to the webservice. But, values are not inserted in tables on server, whereas if I run the webservice in browser, it inserts the values. So where is the problem exactly?
https://coderwall.com/p/5nccwq
Failed to load resource under Chrome
I referred the second link and tried to change according to the first answer in it, but doesn't work.
I tried to execute it in incognito mode, but no use.
Please help with your answers.
var targeturl="http://hostname/projfolder/webservice.php?orderList="+str_table;
console.log(targeturl);
$.ajax({
type:"POST",
url:targeturl,
contentType: "application/json; charset=utf-8",
crossDomain:true,
dataType:'jsonp',
success:function (data)
{
alert("in success");
var parsedata=JSON.parse(JSON.stringify(data));
alert("parsedata: "+parsedata);
var stats=parsedata["Status"];
alert("logindata: "+stats);
if("1"==stats)
{
alert("success");
}
else
{
alert("failed");
}
}
});
Actually I had forgot adding http://
, but I did it now, now here I get Unexpected token :
error
I used many web services for the same project but did not go through such issue.
Upvotes: 0
Views: 5537
Reputation: 7452
Your server should understand and respond in JSONP. It cannot simply return JSON.
Example:
{status:"1", msg:"success"}
callback({status:"1", msg:"success"})
callback
is random string
that is automatically generated by JQuery and set in the query string of the request URL with parameter named callback
.Please read:
http://api.jquery.com/jquery.getjson/
http://en.wikipedia.org/wiki/JSONP
Upvotes: 1