jquery ajax执行后台方法
作者:bea
代码如下: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="script/jquery-1.3.2.js" type="text/jscript"></script> <script type="text/jscript"> functi
代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="script/jquery-1.3.2.js" type="text/jscript"></script>
<script type="text/jscript">
function show(num) {
var params = '{str:"'+ num+'"}';
$.ajax({
type: "POST",
url: "default.aspx/aa",
data: params,
dataType: "text",
contentType: "application/json; charset=utf-8",
beforeSend: function(XMLHttpRequest) {
$('#show').text("正在查询");
},
success: function(msg) {
$('#show').text(eval("(" + msg + ")").d);
},
error: function(xhr, msg, e) { alert(msg); }
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="click" onclick="show('执行成功');">点击我! </div>
<div id="show" ></div>
</form>
</body>
</html>
后台方法:
代码如下:
[System.Web.Services.WebMethod()]
public static string aa(string str)
{
return str;
}
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 对 lightbox JS 图片控件进行了一下改造, 使其他支持复杂的图片说明
- js 强制弹出窗口代码研究-又一款代码
- js 数组克隆方法 小结
- vs2003 js文件编码问题的解决方法
- Jquery AutoComplete自动完成 的使用方法实例
- JavaScript 对象的属性和方法4种不同的类型
- jQuery 前的按键判断代码
- Javascript 匿名函数及其代码模式原理
- JS 有名函数表达式全面解析
- Jquery Ajax学习实例6 向WebService发出请求,返回DataSet(XML) 异步调用
- JavaScript 高效运行代码分析
- JS setCapture 区域外事件捕捉
- javascript 实现滚动效果代码整理
- JavaScript 无缝上下左右滚动加定高定宽停顿效果(兼容ie/ff)
- 小议Javascript中的this指针
- js实现的类marquee水平循环滚动
- js 把字符串当函数执行的方法
- jQuery each()方法的使用方法
- jQuery each()小议