Ajax Cross Domain Calls

2019-01-08 00:06发布

Can we make Ajax request to a different instance of server(different port) running on the same machine

3条回答
Melony?
2楼-- · 2019-01-08 00:29

Different port means different domain for the browser. So you will hit the cross-domain barrier.

Like Stuart said, you could try using JSONP.

If you are using jQuery, I'd recommend http://code.google.com/p/jquery-jsonp/ if you want it to be as painless as possible.

查看更多
一夜七次
3楼-- · 2019-01-08 00:30

If you use easyXSS (http://easyxss.net) and follow the example at http://xsslocal.kinsey.no/projects/easyxss/example/methods.html, then you could do this quite easily by having a document on the domain that the xhr-request are hitting doing the real requests.

查看更多
Fickle 薄情
4楼-- · 2019-01-08 00:33

With some trickery. Try JSONP.

查看更多
登录 后发表回答