Sonp is simply a hack to allow web apps to retrieve data across domains. It could is said that it violates the same Origin Policy (SOP).
The the-it works is by using Javascript to insert a "script" element into your page. Therefore, you need a callback function. If you didn ' t
There is one, your Javascript would have no-to access the JSON object. But by using JSONP, your Javascript code can call the callback
function. So you must specify the callback name. So your function might look like this:
private static String getJSONPObject(String callback, String s) throws JSONException { return callback + "(" + new JSONObject(s) + ")";}
JSON format:
{ "message": "Get Succeeded", "state": "1", "result": {"name": "Workgroup 1", "id": 1, "description": "11"}}
JSONP format:
Callback ({ "message": "Get Succeeded", "state": "1", "result": {"name": "Workgroup 1", "id": 1, "description": "11"}})
Jquery插件:
https://github.com/congmo/jquery-jsonp
Json, Jsonp