【发布时间】:2013-07-26 07:10:45
【问题描述】:
我当前的应用程序中有一个 htm 页面和一个 service.aspx 和 service.aspx.cs 文件。我正在使用.Net 4.0。在 service.aspx.cs 页面中,我有如下测试方法。
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)]
public static string test()
{
return "AA";
}
在我的html页面中
$.ajax({
type: "GET",
cache: false,
url: "NextGenFormService.aspx/test",
dataType: "xml",
contentType: "text/html",
success: AjaxSucceeded,
error: AjaxFailed
}); //end of $.ajax;
如果我在我的服务器中保留一个断点,它就不会命中。 AjaxSucceeded 被 200 OK 调用,responseText 为空。
同样适用于内容类型:应用程序/json,数据类型:json。
我试图从服务器或测试方法发送的只是 html 和 JavaScript。
【问题讨论】:
-
已在浏览器中检查了您的网址是否有效?
-
尝试安装 Fiddler2 来监控您的请求。该请求说明了什么?
-
提琴手响应为空。
-
和跨域有关系吗?但为什么同样适用于 json 数据类型和内容类型。