demo1:
<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<meta name="viewport" content="width=device-width, initial-scale=1.0"> ???<meta http-equiv="X-UA-Compatible" content="ie=edge"> ???<title>JSONP</title></head><body id="body"> ???<div id="divCustomers"></div> ???<script type="text/javascript"> ???????function callbackFunction(result, methodName) { ???????????let html = ‘<ul>‘; ???????????for (let i = 0; i < result.length; i++) { ???????????????html += `<li>${result[i]}</li>` ???????????} ???????????html += ‘</ul>‘; ???????????document.getElementById(‘divCustomers‘).innerHTML = html; ???????} ???</script> ???<script type="text/javascript" src="http://www.runoob.com/try/ajax/jsonp.php?jsoncallback=callbackFunction"></script></body></html>
demo2:
前端跨域之jsonp
原文地址:https://www.cnblogs.com/sangzs/p/9004119.html