当前在线人工客服
天达云-技术
QQ:1324027256
天达云-技术
QQ:1902643386
天达云-售前
QQ:1650874901
天达云-售前
QQ:2207995833
天达云-合作
QQ:1984186903
天达云微信小程序
400-837-6568

jQuery ajax 跨域请求
更新:HHH   时间:2023-1-7


jQuery官方apigetJSON(http://api.jquery.com/jQuery.getJSON/)的说明中有这样一段

AdditionalNotes:

  • Duetobrowsersecurityrestrictions,most"Ajax"requestsaresubjecttothesameoriginpolicy;therequestcannotsuccessfullyretrievedatafromadifferentdomain,subdomain,orprotocol.

  • ScriptandJSONPrequestsarenotsubjecttothesameoriginpolicyrestrictions.

    所以一般的ajax跨域请求返回不了什么东东的。只有script和jsonp两种可以返回。

    举例:

    对于jsonp,有url?jsonCallBack=?

    在后台,如jsp中如最后这样写Stringjson="{\"name\":\"LP\"}";out.print("jsonCallBack("+json+")");

返回web开发教程...