我对这样的WebMethod进行了ajax调用(使用jquery):
function CardLogin() {
Card_Num = document.getElementById("body_CardNumber");
Card_Serial = document.getElementById("body_CardSerialNumber");
var dataValue = {"Card_Num": Card_Num.value , "Card_Serial": Card_Serial.value };
$.ajax({
type: "POST",
url: "Ajax_load.aspx/Card_Login",
data: JSON.stringify(dataValue),
processData: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (XMLHttpRequest, textStatus, errorThrown) {
$(".display_error").html("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
return false;
},
complete: function (jqXHR, status) {
console.log(jqXHR);
$(".display_error").html("complete: " + status + "\n\nResponse: " + jqXHR.responseText);
return false;
}
});
}
像这样的网络方法
[WebMethod]
[ScriptMethod]
public static string Card_Login(string card_num, string card_serial)
{
return ("done");
}
但不是将结果作为"完成"我有一个例外 "无效的Web服务调用,缺少参数值:\ u0027card_num \ u0027" 从几次调试尝试中我了解到它可能是数据类型问题。我做错了什么?