ajax - Does JSONP require server modifications? -


I think jsonp is a technique to meet around the same basic policy. You basically refer to your Jason service server endpoint in a script tag, because script tags are free from SO policy.

My question is this: There is a closing point assuring a server that works on JSO, is there any necessary modification on the server to use JSNP in the client?

I do not think so, but want to make sure ....

Yes, JSONP is slightly different when it renders, then your server needs to support it.

JSON looks like this:

  {"name": "value"}  

While JSONP looks like this:

  functionName ({"name": "value"});  

If you are using it, it is supported, but it is not only going to support JSON. When the server receives a request, for example: http://example.com/json?callback=functionName above is what you should present, as it looks in this page Is:

  & lt; Script type = "text / javascript" src = "http://example.com/json?callback=functionName" & gt; & Lt; / Script & gt;  

This means that the runs need to return, for example, it is valid:

  & lt; Script type = "text / javascript" & gt; FunctionName ({"name": "value"}); & Lt; / Script & gt;  

If your server supports not JSONP, then it will be effectively:

  & lt; Script type = "text / javascript" & gt; {"Name": "value"} & lt; / Script & gt;  

... and you will get syntax errors, because this is not a valid JavaScript.


Comments