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

查看:64
本文介绍了访问受限的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

我也签出了以下链接-

访问受限制的URI拒绝代码:1012

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

我也尝试了url中的Callback. 我已经看到了关于此问题的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.

请注意,张贴到远程登录表单可能是为什么浏览器不允许这样的跨域请求的最佳示例.您不希望有一个看起来像您的银行的页面能够实际从您的银行网站为您提供数据的页面-这样的网页将非常有效.

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.

另一方面,如果您真的想解决此问题,则可以编写一些服务器端代码,这些代码在给定输入参数的情况下向redirectURL发出发布请求,然后将响应汇集到一起.

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被拒绝".代码:"1012-跨域Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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