开发者

Virtual Forms vs Ajax POST

开发者 https://www.devze.com 2023-03-16 21:41 出处:网络
Ajax can\'t do cross-domain post due to the same-origin policy.But, if we use Ajax to dynamic create a virtual form and do a cross-domain post, then the browser allows it.

Ajax can't do cross-domain post due to the same-origin policy. But, if we use Ajax to dynamic create a virtual form and do a cross-domain post, then the browser allows it.

Aren't they doing the same thing? Why does the browser al开发者_如何学Clow one but not the other?


Ajax can - it's called JSONP (Padded JSON). jQuery has this built into it's ajax object

$.ajax({
url:'http://www.otherdomain.com',
crossDomain:true,
...
});
0

精彩评论

暂无评论...
验证码 换一张
取 消