开发者

jQuery "Access Is Denied" Error

开发者 https://www.devze.com 2022-12-31 07:43 出处:网络
I have an $.ajax() request that queries currency exchange rate information from another web server, which is the reason (I believe) for which I am getting an \"Access Is Denied\" error on the $.ajax()

I have an $.ajax() request that queries currency exchange rate information from another web server, which is the reason (I believe) for which I am getting an "Access Is Denied" error on the $.ajax() call.

开发者_如何学C

Is there a way to permit this type of activity?


Yes, you could use JSONP if the remote server can support it (works only with GET requests and it works with the .ajax function as well). Another option is to create a bridge server script on the same domain.

Here's an article that may help you get started.

Here's how it works:

The server must send the data using the following format:

callback({name : "Smith", id : 1})

where callback must be configurable.

So basically jQuery includes a script tag inside the DOM:

<script type="text/javascript" src="http://distantdomain.com/?jsonp_callback=someRandomName"></script>

and the someRandomName function will be executed and passed the JSON object.

0

精彩评论

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

关注公众号