【发布时间】:2012-04-06 00:09:29
【问题描述】:
我在 url 中有一些 asmx Web 服务(即 example.com/Entities/WebServices 假设 example.com 是我的域)。这样做的目的是能够从所有应用程序中访问像员工一样的域数据。因此,对于获取员工数据的每个示例,我使用方法example.com/Entities/WebServices/EmployeeWs.asmx/GetAll
当我尝试使用 JQuery.Ajax 从本地主机获取员工数据时,它在 IE8 上运行良好。但是在使用 Firefox 时,$.ajax 调用将我发送到成功函数但带有一条空消息(还检查了 firebug 的响应,它是 200 OK - 0byte)
我已经把 jQuery.support.cors = true;但它在 Firefox 或 chrome 中没有帮助。
我也尝试在example.com/TestProject 中发布测试应用,但结果是一样的。它只适用于 IE。
有人知道错误的原因吗?
使用 IE8、Firefox 8.0.1、Chrome 11.0.6。 jQuery 1.7.1
提前致谢。
var requestedUrl = "http://example.com/Entities/WebServices/EmployeeWs.asmx/GetAll";
jQuery.support.cors = true;
$.ajax({
type: "POST",
contentType: "application/json",
url: requestedUrl,
dataType: 'json',
contentType: "application/json; charset=utf-8",
success:
function(result) {
alert("ok. " + result);
},
error:
function(xhr) {
alert("err. " + xhr.responseText);
}
});
【问题讨论】:
标签: jquery asp.net ajax firefox google-chrome