AJAX Http POST:没有传输错误
AJAX Http POST : No transport error
这是我的网络方法:
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
这是html页面中的AJAX代码:
jQuery.support.cors = true;
var btn_startOp = document.getElementById("startOpp");
$.ajax({
type: "POST",
contentType: "application/xml; charset=utf-8",
data: "{}",
dataType: "xml",
url: "http://localhost:61457/WebSite1/Service.asmx/HelloWorld",
success: function(msg){ alert(msg.d); },
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
这给了我一个错误:开,
- IE浏览器:无传输
- Mozilla:未知
在浏览器上测试时,Web服务运行良好。
更新:这是Html:中head标签中的行
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
有人能帮我吗?这是我的第一个代码。我搜索了很多,对我来说仍然是个谜…:):(
更改为:
$.ajax({
type: "GET",
url: "/WebSite1/Service.asmx/HelloWorld",
dataType:"json",
success: function(msg) {
alert(msg);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
- 您正在从Web方法返回一个字符串值,因此不需要
dataType:"xml"
- 在浏览器上测试时,Web服务运行良好,这意味着您需要有一个
GET
请求
相关文章:
- AJAX简单错误.XMLHttpRequest无法加载http://localhost/mpl/getPage.php.
- spring和angularJS(我得到了类似HTTP状态404的错误)
- $http服务未触发成功或错误回调
- 为什么我在Cloud9中的http请求总是返回错误
- 为什么我的$http.post返回一个400错误
- AngularJS$http.post调用返回502(坏网关)错误
- "所请求的名称已经作为不同类型的“”存在;HTTP 409响应错误
- 岗位http://localhost:3000/api/signup400(错误请求)
- $http GET URL更改并查找错误的资源
- cordova图像上传出现文件传输错误
- socket.io:断开连接事件 - “传输关闭”、“客户端命名空间断开连接”、“传输错误”和“强制关闭”
- AngularJs 错误:$http请求虽然在控制器中定义
- GWT应用程序中出现错误HTTP 404(“Script Tag Failure-no status available
- AJAX Http POST:没有传输错误
- 限制 Node.js 中同时通过管道传输的 HTTP 请求
- 在openmeetings中上载/共享文件时出现错误HTTP:500
- Angular HTTP GET 与 TypeScript 错误 http.get(..).映射不是 [null] 中的
- browserify 错误:http.createServer 不是一个函数
- 未捕获错误:[$http:badreq] Http 请求配置 url 必须是字符串 (AngularJS)
- PhoneGap文件传输错误1,在哪里写FileTransfers