0
に私はこのような簡単なHTMLページを書かれている: すべての私のファイルと同じフォルダ内にある「未定義は:0ステータス::0 responseTextのreadyStateを」はJQueryのWebサービスの呼び出し常にエラー
<!DOCTYPE html>
<HTML>
<HEAD>
</HEAD>
<form name="form">
<input type="text" id="messageTest" name="msg" value="Your message"/>
<input type="submit" id="login" />
</form>
<script type="text/javascript" src="jquery.js"></script>
<script>
document.getElementById("login").addEventListener("click", function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: "Test.asmx/HelloWorld",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert(msg.d);
},
error: function(xhr,err){
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
alert("responseText: "+xhr.responseText);
}
});
}, false);
</script>
</HTML>
それは常に返します。 これは私のWebサービスです。
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class Test : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
は私が間違っているの何かがありますか?
どのconsole.log(エラー);コンソールに表示されますか? –
「エラー」が表示されます。 – Stan
この答えを見て、それはあなたが必要なものかもしれません:http://stackoverflow.com/a/11052049/1220550 –