0
我一直在試圖從php應用程序中調用一個jQuery Ajax調用ASP.NET web服務。我試過用jsonp,但結果總是一樣的。它總是給我一個錯誤的結果,當我試圖看到錯誤時,它只給了我一個空白的結果。我試着添加和刪除ajax調用的屬性來查看它是否工作,但仍然沒有結果。至於網絡服務,我100%肯定它工作正常。Jquery ajax調用總是返回ASP.NET web服務上的錯誤
因此,這裏是我的AJAX調用的代碼:
function submitClicked(){
var url = "http://localhost/MyWebService/service1.asmx/HelloWorld";
$.ajax(url, {
dataType: "jsonp",
type:'POST',
success: function (data) {
successCallback(data);
},
error:function(error){
console.log("error");
}
});
}
下面是VB.NET中我的web服務代碼:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Sub HelloWorld()
Context.Response.Clear()
Context.Response.ContentType = "application/json"
Context.Response.Flush()
Context.Response.Write("{""success"":1}")
End Sub
任何幫助將高度讚賞。謝謝。
乾杯。