我運行的asmx服務中的一個端口本地主機:5739,並試圖從其他端口撥打服務或普通的HTML + jQuery的出項目的無法通過jQuery來調用ASMX Web服務的Ajax
,但我不能訪問Web服務
我的web服務是
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld(string text) {
return "Hello World" + text;
}
和我的代碼來調用Web服務是
$.ajax(
{
type: "POST",
url: "http://localhost:5739/asmxservices/testservice.asmx/HelloWorld",
data: '{ "text": "Kartheek"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
});
function OnSuccess(data, status) {
alert(data.d);
};
function OnError(msg) {
alert('error = ' + msg.d);
}
什麼是錯誤?錯誤的格式,404,?可能重複http://stackoverflow.com/questions/811353/escaped-json-response-with-webmethod – Cybermaxs
總是會進入OnError(msg)函數。並顯示未定義從msg.d – Kartheek