ajax请求本页面后台方法



$.ajax({
url: "Default.aspx/Method",
data: "{name:'hh',password:'123'}",
type: "post",
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function(msg) {

},
error: function(xhr) {
}
});

后台方法
[WebMethod]
public static string Method(string name,string password)
{
return "aa";
}

url:"本页面名称/方法名称";data的格式为json格式;dataType: "json";contentType:"application/json;charset=utf-8";msg.d通过.d属性来取服务端返回的数据
后台方法里的注意地方:
方法由[WebMethod]修饰;方法必须是公共的静态方法;方法里的参数名称必须与脚本里data的参数名一样,顺序可以不一样


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM