看來這應該是一件簡單的事情,但我無法調用我的web服務調用。這裏是我的代碼:無法讓webservice識別我的參數
var data = '{"deviceId":"e9b3f993-7ca1-442b-a5c2-001ab86e1af4","opid":202,"remarks":"fefawef"}';
$.ajax({
url: 'MyPage.aspx/MyMethod',
data: data,
type: 'GET',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
// Do stuff
},
error: function(xhr) {
alert(xhr.responseText);
}
}); // end $.ajax
乍一看,你可能會問,是否有更合適,而不是使用GET POST。它可能會,但我使用GET來避免討厭的Internet Explorer 12030錯誤問題。
我的Web方法的簽名如下所示:
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public static string MyMethod(string deviceId, int opid, string remarks)
最後,我看到的錯誤是Invalid web service call, missing value for parameter: deviceId
。我看不出問題會是什麼。 deviceId
在傳入的JSON字符串文字清楚顯示
請問您的Web服務支持JSON參數?這不完全是一個普遍的事情。 – 2012-08-03 21:19:21