function MyAjax(uid, pwd) {
$.ajax({
type: "POST",
dataType: "json",
data: "{userid:'" + uid + "',password:'" + pwd + "'}",
url: "ajax.aspx/GetData",
success: function (msg) {
alert(msg.d); },
error: function (msg) { alert("oh,bugger!"); } })}我写得是否有问题呢,执行总是返回error 的结果,后台是这样的: [WebMethod]
public static string GetData(string userid,string password)
{
if (userid == "lu" && password == "123456")
{
return "1";
}
return "0"; }
$.ajax({
type: "POST",
dataType: "json",
data: "{userid:'" + uid + "',password:'" + pwd + "'}",
url: "ajax.aspx/GetData",
success: function (msg) {
alert(msg.d); },
error: function (msg) { alert("oh,bugger!"); } })}我写得是否有问题呢,执行总是返回error 的结果,后台是这样的: [WebMethod]
public static string GetData(string userid,string password)
{
if (userid == "lu" && password == "123456")
{
return "1";
}
return "0"; }
url: "ajax.aspx",后台onload事件里面 GetData(context.Request.Form["userid"].tostring(),context.Request.Form["userid"].tostring());
function MyAjax(uid, pwd) {
$.ajax({
type: "POST",
dataType: "json",
data: '{"userid":"' + uid + '","password":"' + pwd + '"}',
url: "ajax.aspx/GetData",
contentType: "application/json; charset=utf-8",
success: function (msg) {
alert(msg.d); },
error: function (msg) { alert(msg.responseText)
}
})
}