ajax传递一个参数具体实现
程序员文章站
2022-05-18 08:32:36
复制代码 代码如下:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="js/jquery1.7.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#txtusername').blur(function () {
$.ajax({
type: "post",
contenttype: "application/json",
url: "webservice1.asmx/validateuser",
data: "{username:'" + $('#txtusername').val() + "'}",
success: function (result) {
$('#spinfo').text(result.d);
}
})
})
})
</script>
</head>
<body>
<div>
用户名<input type="text" id="txtusername" /><span id="spinfo"></span><br />
密码<input type="text" id="txtpwd" />
</div>
</body>
</html>
复制代码 代码如下:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="js/jquery1.7.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#txtusername').blur(function () {
$.ajax({
type: "post",
contenttype: "application/json",
url: "webservice1.asmx/validateuser",
data: "{username:'" + $('#txtusername').val() + "'}",
success: function (result) {
$('#spinfo').text(result.d);
}
})
})
})
</script>
</head>
<body>
<div>
用户名<input type="text" id="txtusername" /><span id="spinfo"></span><br />
密码<input type="text" id="txtpwd" />
</div>
</body>
</html>
上一篇: ajax传递多个参数具体实现