【问题标题】:$.getJSON() fails in chrome but works fine in ie$.getJSON() 在 chrome 中失败,但在 ie 中工作正常
【发布时间】:2013-10-29 22:05:38
【问题描述】:
$.getJSON(loginURL,
                            {
                            });
                    $.ajax({
                        type: "GET",
                        dataType: "json",
                        headers: {Accept: "application/json"},
                        crossDomain: false,
                        url: loginURL,
                        success: function(loginFlag)
                        {



                        },
                        error: function(xhr, textStatus, errorThrown)
                        {


                        }
                    }
                    );

loginURL 使用上下文名称和服务器需要处理的参数进行配置。该调用在 ie 中运行良好,但在 chrome 中失败。当我从 chrome 尝试时调用 getJson 的错误方法,但在尝试使用 ie 时调用成功。 例如:var loginURL = "/GameApplicationWeb_v4/service/checkusercredentials/uname/name/password/name@game"

【问题讨论】:

  • 使用 Fiddler 或开发者工具的网络标签来确定从 Chrome 发送调用时服务器返回的内容。
  • 是的,呼叫已从 chrome 发出。现在我已经在代码中添加了更多的标头属性,现在它可以工作了。

标签: ajax internet-explorer google-chrome rest call


【解决方案1】:
$.getJSON(loginURL,
                            {
                            });
                    $.ajax({
                        type: "GET",
                        dataType: "json",
                        headers: {Accept: "application/json"},
                        crossDomain: false,
                        url: loginURL,
                        async: false,
                        cache: false,
                        success: function(loginFlag)
                        {
                        }, 
                        error   ()
                         {
                         });

我添加了更多的标头属性(aync 和缓存),现在它工作正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-03
    • 2016-07-07
    • 1970-01-01
    相关资源
    最近更新 更多