【发布时间】:2012-05-04 16:06:59
【问题描述】:
这可能是我遇到过的最奇怪的错误:
所以我有一堆 jQuery.ajax 调用,我把它们放在一起的 Web 服务。它在 Firefox 和 Chrome 中运行良好,但在 IE8 中没有任何作用除非我运行了 Fiddler。 (这与here 报告的问题类似,但我已经尝试过提到的东西,但无济于事。)
在这些非功能调用中,它似乎正在按应有的方式构建 jqXHR 对象,但缺少一些东西。不过不知道是什么——我对 jQuery 的内部工作方式并不是非常熟悉,所以在调试器中单步执行调用对我来说只能做这么多。
来电:
$.ajaxSetup({
type: "POST",
timeout: 30000,
contentType: "application/json; charset=utf-8"
});
$.ajax({
url: "/PSWS/UserManager.asmx/Login",
data: '{"emailAddress":"' + myEmailAddress + '","password":"' + myPassword + '","stayLoggedIn":' + (myStayLoggedIn ? 'true' : 'false') + '}',
success: function (response) {
if (!response.Success) {
alert(response.Message);
} else {
$(this).find('.message').remove();
$.fn.colorbox.close();
}
},
dataType: 'json',
error: function (jqXHR, textStatus, errorThrown) {
$(this).find('.message').remove();
$(this).prepend('<div class="message message_error">Error!<br/>' + jqXHR.status + ' - ' + jqXHR.statusText + '</div>');
}
});`
我想知道我的 JSON 是否有问题,无论是发送的还是接收的。除了通过 Fiddler 之外,我不知道有什么方法可以捕捉到这一点,但它似乎是有效的。无论如何,对于它的解析器和 JSONLint 来说足够有效。
发送:
{"emailAddress":"test@example.com","password":"asdasdasd","stayLoggedIn":true}
收到:
{"__type":"PSUserManagerService.SystemResponse","Success":false,"Message":"Error logging in: Invalid username and/or password.","Subscriptions":null}
【问题讨论】:
标签: jquery ajax json web-services internet-explorer-8