IE中HTTPS Ajax请求的问题(非跨域)

发布于 2024-12-29 09:05:25 字数 571 浏览 1 评论 0原文

我对仅在 IE 中进行 HTTPS Ajax 调用时遇到的问题感到困惑。 IE 似乎认为我正在发出跨域请求,但事实并非如此。从页面 https://mydomain/customer_profile.php 调用以下代码:

$.ajax({
    type: 'post',
    url: 'https://mydomain/ajax/retrieve_transaction_details.php',
    data: /* my data is here */,
    success: function(response){
        // do something with the response
    },
    error: function (xhr, ajaxOptions, thrownError){
        alert(xhr.status);
        alert(thrownError);
    }
});

此请求在除 IE 之外的所有浏览器中都可以正常工作。在 IE 中,错误函数返回“错误:访问被拒绝”。就像我说的,我完全被难住了,所以任何见解或想法都会很棒。

I'm stumped on an issue I'm having with an HTTPS Ajax call in IE only. IE seems to think I'm making a crossdomain request, but I'm not. The following code is called from the page https://mydomain/customer_profile.php:

$.ajax({
    type: 'post',
    url: 'https://mydomain/ajax/retrieve_transaction_details.php',
    data: /* my data is here */,
    success: function(response){
        // do something with the response
    },
    error: function (xhr, ajaxOptions, thrownError){
        alert(xhr.status);
        alert(thrownError);
    }
});

This request works just fine in every browser except IE. In IE, the error function returns "Error: Access is denied". Like I said, I'm completely stumped on this, so any insight or ideas would be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黎歌 2025-01-05 09:05:25

我猜您正在 HTML 的 head 部分中使用 标记;正确的?

如果它指向 http 而不是 https,则会破坏 IE

I guess you are using the <base> tag inside the head section of your HTML; right?

If it is pointing to http instead of https, that would break IE.

め七分饶幸 2025-01-05 09:05:25

尝试在您的请求中将 crossDomain 设置为 true,如下所示:

$.ajax({
    type: 'post',
    url: 'https://mydomain/ajax/retrieve_transaction_details.php',
    data: /* my data is here */,
    crossDomain: true,
    success: function(response){
        // do something with the response
    },
    error: function (xhr, ajaxOptions, thrownError){
        alert(xhr.status);
        alert(thrownError);
    }
});

这应该允许您发出请求,无论它是否跨域。

try setting crossDomain to true in your request like this:

$.ajax({
    type: 'post',
    url: 'https://mydomain/ajax/retrieve_transaction_details.php',
    data: /* my data is here */,
    crossDomain: true,
    success: function(response){
        // do something with the response
    },
    error: function (xhr, ajaxOptions, thrownError){
        alert(xhr.status);
        alert(thrownError);
    }
});

this should allow you to make the request regardless of whether it is cross-domain or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文