Invalid Label error in JSONP
my json url is :
http://app.websitename.in/getToken
above url return me following JSON :
{ token: "2cd3e37b-5d61-4070-96d5-3dfce0d0acd9%a00a5e34-b017-4899-8171-299781c48c72" }
Edit: Changed it to
{ "tok开发者_高级运维en": "2cd3e37b-5d61-4070-96d5-3dfce0d0acd9%a00a5e34-b017-4899-8171-299781c48c72" }
I am (still) getting Invalid Label error while calling following code
my code is :
$.getJSON("http://app.websitename.in/getToken?callback=?",
function(data) {
alert("success");
alert("Symbol: " + data.token);
});
Please help me
Thanks
Property names must be in double quotes to be valid JSON, e.g.:
{ token: "2cd3e37b-5d61-4070-96d5-3dfce0d0acd9%a00a5e34-b017-4899-8171-299781c48c72" }
must be
{ "token": "2cd3e37b-5d61-4070-96d5-3dfce0d0acd9%a00a5e34-b017-4899-8171-299781c48c72" }
(Note that "token" is now in double quotes.)
Details on the JSON site. JSONlint is also helpful.
Some JSON parsers are lax and let you get away with not putting double quotes around property names (particularly ones that are really JavaScript parsers in disguise), but technically, it's required.
my json url is : http://app.websitename.in/getToken
No, it isn't (or, if it is, then its broken).
curl: (6) Couldn't resolve host 'app.websitename.in'
If we assume that you mean "example.com" when you say "websitename.in" (use the example domains for examples, that is what they are there for) then:
If it returns that data, in that form, then it is failing to wrap it in a callback, so it is JSON and not JSON-P. You need JSON-P to operate across domains.
精彩评论