我使用ASMX来检索数据库的一些数据,asmx web服务,json,javascript/jquery?
public class TestPage1
{
public int UserID { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string MiddleName { get; set; }
}
[WebMethod]
public EntityLayer.TestPage1 GetData(int id)
{
TestPage1 test = TestPage1.GetData(id).SingleOrDefault();
return test;
}
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/GetData",
data: "{id}",
dataType: "json"
});
我如何desrialize测试对象在JavaScript? 有没有更好的方法? 感谢
任何人都想尝试这一点 - 不要忘记用[ScriptService]标记您的WebService类 - 只是有问题。 – kape123 2012-05-25 13:44:21