【问题标题】:Trouble in redirecting to another page from IE after ajax post (Description Inside)ajax 发布后从 IE 重定向到另一个页面的问题(内部描述)
【发布时间】:2014-07-28 09:24:06
【问题描述】:

假设我有 2 个 html 页面,

  1. index.html
  2. info.html

index.html 包含一个用于查看 info.html 的注册表单,它将注册详细信息保存到服务器并重定向到 info.html 页面。

它适用于除 Internet Explorer 之外的所有浏览器。但在 IE 中它不会重定向。我正在使用以下代码,

function StartService(param) {
var ajaxUrl = "/WebService.asmx/Notify";

    $.ajax({
    type: "POST",
    crossDomain: true,
    contentType: "application/json; charset=utf-8",
    url: ajaxUrl,
    data: param,
    dataType: "json",
    success: successTest,
    error: errorTest
});

function successTest(data) {
    var result = data.d;
    //console.log(result);
    if (result === 'success') {
        setTimeout(function () { window.location.href = 'info.html'; }, 3000);
    } else {
        alert(result);
    }
}

function errorTest(xhr, textStatus, errorThrown) {
    console.log(xhr.responseText);
}

}

有人可以帮忙吗?

【问题讨论】:

  • 它记录的内容“console.log(result);” ?
  • @JitendraPancholi 它记录“成功”
  • 你试过用 == 代替 === 吗?
  • @JitendraPancholi 是的,它不工作。
  • 任何特定版本的 IE 都会产生问题?

标签: javascript jquery html ajax internet-explorer


【解决方案1】:

您是否尝试过在 window.location.href 语句中使用绝对 url?

IE 可能会遇到问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    • 1970-01-01
    • 2016-05-07
    • 2017-06-05
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    相关资源
    最近更新 更多