First of all , I know how jsonp works.
it injecting js code as callback ({a:1})
from a server who supports these kind of requests.
I have this code which connects to facebook , and they return an invalid json result.
they do support jsonp cause using jquery ajax with datatype:jsonp - DOES return value ( invalid one though)
the response from jsonp call is :
for(;;); //<----------- the problem
{
"__ar": 1,
"error": 1357001,
"errorSummary": "Not Logged In",
"errorDescription": "Please log in to continue.",
"payload": {
"__dialog": {
"title": {
"__html": "Not Logged In"
},
"body": {
"__html": "Please log in to continue."
},
"buttons": [
{
"name": "login",
"label": "Log In",
"handler": "goURI(\"\/login.php\", true);"
}],
"modal": true,
"onloadRegister": ["setInterval(function () {\n if (getCookie(\"c_user\") || getCookie(\"csm\")) {\n window.location.reload();\n }}, 5000);"]
}
},
"js": ["8fTQS"],
"resource_map": {
"8fTQS": {
"type": "js",
"src": "https:\/\/s-static.ak.fbcdn.net\/rsrc.php\/v2\/y9\/r\/NXhpMFxH7x0.js"
}
}
}
Of course- this is an invalid json.
Firebug :
When I paste this text to jsonlint , and remove the first line - it is a valid json.
If I could remove the for(;;);
line from the result - I could have parse the result.
I want to catch the textual response and replace for(;;);
with empty string.
I want to jquery documentation and I noticed this info :
I did try to write jsonp text
but still error.
How can I get the result and replace the for(;;);
with empty string without showing the error ?