问题描述
||
我正在尝试使用Java脚本访问.Net中构建的Web服务。
<html>
<head>
<title>Test Web service</title>
<script type=\"text/javascript\">
function httptest(){
var http = new XMLHttpRequest();
var params = \"\";
var RetFlag = \"Webmail-\"+ false;
http.open(\"Post\",\"http://localhost:3624/_anet/wsCoverageValidate.asmx/CheckCoverage\",false);
http.setRequestHeader(\"Content-type\",\"application/x-www-form-urlencoded\");
http.setRequestHeader(\"Content-length\",params.length);
http.setRequestHeader(\"Connection\",\"close\");
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var resp=http.responseText;
alert(resp);
}
}
http.send(params);
}
</script>
</head>
<body>
<div style=\"float: left; width: 100%; background-color: Gray;\">
<button id=\"btngo1\" value=\"Go\" type=\"submit\" onclick=\"httptest()\">
Go
</button>
</div>
</body>
</html>
这是我的Javascript HTML页面。现在,它可以在Internet Explorer上正常运行,但是在从firefox访问时会出现问题。它给了我JavaScript错误
Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)
,在错误控制台中。我为此进行了很多搜索,但没有成功。
请帮我。
谢谢
解决方法
我已经得到我问题的答案,无法在本地测试。 Mozilla提供了这种类型的安全性。
当我将html文件上传到服务器上并从PC上调用时,它可以正常工作。 ]
我从这里得到答案
谢谢大家
,下载jQuery并将源添加到HTML页面中。
<script type=\"text/javascript\" src=\"jquery.js\"></script>
遵循本教程以获取更多信息-http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
访问Web服务
<script type=\"text/javascript\">
function httptest(){
$.post(\'http://localhost:3624/_anet/wsCoverageValidate.asmx/CheckCoverage\',function(data) {
alert(data);
});
</script>