Method for sending a JSONP request using the Script element, scriptjsonp
How to send a JSONP request using the Script Element
// Send a JSONP request based on the specified URL // then pass the parsed data to the callback function // Add a query parameter named jsonp to the URL, function getJSONP (url, callback) {// create a unique callback function name for this request var cbnum = "cb" + getJSONP. counter ++; var cbname = "getJSONP. "+ cbnum; if (url. indexof ("? ") =-1) {url + = "? Jsonp = "+ cbname;} else {url + =" & jsonp = "+ cbname;} var script = document. createElement ("script"); getJSONP [cbnum] = function (response) {try {callback (response);} finally {delete getJSONP [cbnum]; script. prentNode. removeChild (script) ;}}; script. src = url; document. body. appendChild (script);} getJSONP. counter = 0;
The above method of sending a JSONP request using the Script element is all the content shared by the editor. I hope to give you a reference and support for the customer's house.