访问受限 URI 被拒绝"代码:"1012 - 跨域 Ajax 请求 [英] Access to restricted URI denied" code: "1012 - Cross domain Ajax request

查看:40
本文介绍了访问受限 URI 被拒绝"代码:"1012 - 跨域 Ajax 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做跨域 Ajax 请求 - 这是我的代码

I Need to do cross domain Ajax request - Here is my code

 $.ajax(
        {
            url: redirectURL,
            data: $('#login-container form').serialize() + querystring,
            type: 'post',
            cache: false,
            dataType: 'jsonp',
            jsonp: 'jsonp_callback',
 });

<小时>

Error: [Exception... "Access to restricted URI denied"  code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"  location: "http://testsite/assets/scripts/jquery-1.3.2.js Line: 19"]
Source File: http://testsite/assets/scripts/jquery-1.3.2.js
Line: 19

我也查看了以下链接 -

I have checkout the following links too -

访问受限 URI 被拒绝代码:1012

 $.ajax(
        {
   url: redirectURL+'?callback=?',
            data: $('#login-container form').serialize() + querystring,
            type: 'post',
            cache: false,
            dataType: 'html' });

我也尝试过在 url 中回调.我已经在stackoverflow中看到了关于这个问题的所有链接..但无法克服这个问题任何人都可以请帮助并告诉我如何克服!谢谢

I have tried Callback in url too . I had already seen all link in stackoverflow regarding this issue.. but not able to overcome this thing Can anyone please help and tell me how to overcome !! Thanks

推荐答案

您将无法在浏览器中执行跨域 POST 请求.

You won't be able to do a cross-domain POST request in the browser.

如果您使用 JSONP 调用来访问跨域 URL,则可以使用 JQuery 的 getJSON 方法.这将允许您仅发出 GET 请求.如果您可以使用 GET 参数将您的登录信息提交到 redirectURL,您就可以完成这项工作.

If you are making a JSONP call to access a cross-domain URL, you can use JQuery's getJSON method. This would allow you to make a GET request only. If you can submit your login information to the redirectURL using GET parameters, you could make this work.

请注意,POST 到远程登录表单可能是浏览器禁止此类跨域请求的最佳示例.您不希望看起来像您的银行的页面能够实际为您提供来自您银行网站的数据 - 这将成为一个非常有效的网络钓鱼页面.

Note that POSTing to remote login forms is perhaps the best example of why browsers disallow cross-domain requests like this. You don't want a page that looks like your bank to be able to actually serve you data from your bank's website -- that would make a very effective phishing page.

另一方面,如果你真的想解决这个问题,你可以编写一些服务器端代码,给定输入参数,向重定向 URL 发出发布请求并返回响应.

On the other hand, if you really want to work around this, you can write some server-side code that, given the input parameters, makes a post request to the redirectURL and funnels back the response.

请告诉我您不是在编写网络钓鱼页面.

Please tell me you are not writing a phishing page.

这篇关于访问受限 URI 被拒绝"代码:&quot;1012 - 跨域 Ajax 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆