jquery 调用asp.net后台代码
2013-08-22 22:46
519 查看
1.需要引用对应的命名空间
System.Web.Services
2.后台方法;
必须是static 约束 必须添加[WebMethod()] 属性
示例:
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script>
function a() {
$.ajax({
type: "post",
url: "WebForm1.aspx/GetString",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.d);
var m = eval("("+data.d+")");
alert(m.name);
}
});
}
</script>
[System.Web.Services.WebMethod()]
public static string GetString()
{
return "{name:'lin'}";
}
System.Web.Services
2.后台方法;
必须是static 约束 必须添加[WebMethod()] 属性
示例:
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script>
function a() {
$.ajax({
type: "post",
url: "WebForm1.aspx/GetString",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.d);
var m = eval("("+data.d+")");
alert(m.name);
}
});
}
</script>
[System.Web.Services.WebMethod()]
public static string GetString()
{
return "{name:'lin'}";
}
相关文章推荐
- jquery调用asp.net 页面后台的实现代码
- jquery调用asp.net 页面后台的实现代码
- JQuery的$.ajax()调用asp.net的后台方法样例代码
- jquery调用asp.net 页面后台的实现代码
- ASP.NET中JQuery+AJAX调用后台
- JQuery调用asp.net后台方法 .
- ASP.NET中前台javascript与后台代码调用
- asp.net后台调用前台脚本代码
- javascript与cs代码互相调用 asp.net中前台javascript与后台C#交互 这里主要包括了javascipt与后台CS代码四种方法互调(其中包括函数与变量的访问)
- 利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法。
- 【原】asp.net1.1中使用jquery调用后台webservice文件
- 利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法
- asp.net调用前台js调用后台代码分享
- jquery ajax调用asp.net 后台方法
- 利用JQuery直接调用asp.net后台方法
- ASP.NET中前台javascript与后台代码调用
- asp.net调用前台js调用后台代码分享
- ASP.NET中JQuery+AJAX调用后台
- JQuery调用asp.net后台方法
- GOOGLE API - 翻译, 后台c# 调用前台js代码, asp.net后台调用js代码