2014-01-28 54 views
0

我想設置一個接受字符串並返回一個字符串的簡單服務。我建立了ASP.net代碼並使用它構建在測試頁面中,但似乎無法從jquery調用服務。從Jquery調用ASP服務

ASP:

<System.Web.Script.Services.ScriptService()> _ 
<System.Web.Services.WebService(Namespace:="https://domain/decode")> _ 
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ 
<ToolboxItem(False)> _ 
Public Class Decode 
    Inherits System.Web.Services.WebService 

    <WebMethod()> _ 
    Public Function Decode(Image64 As String) As String 

     Dim Code As String = "test" 
     Return Code 
    End Function 

End Class 

然後我試圖調用從jQuery的這個服務的現有的PHP頁面:

<script src="js/jquery-1.9.1.js"></script> 
<script language="javascript" type="text/javascript"> 
$(function() { 

      $.ajax({ 
       type: "POST", 
       url: "https://domain/decode/decode.asmx/Decode", 
       data: {Image64: ""}, 
       contentType: "application/json; charset=utf-8", 
       dataType: "json", 
       success: OnSuccess, 
       error: OnError 

     }); 
}); 
     function OnSuccess(data, status) 
     { 
      alert(data.d); 
     } 

     function OnError(request, status, error) 
     { 
      alert(request.statusText); 
     } 

我試圖改變數據格式data: "{}"等,並我不斷收到「內部服務器錯誤」。

我想,因爲我完全陌生的東西可能是錯誤的ASP的一面,但不能想出什麼......

回答