ajax传递一个参数具体实现

ajax传递一个参数或多个参数在使用过程中由于特殊需求经常会用到,下面与大家分享下具体的实现方法,感兴趣的朋友可以参考下哈

复制代码 代码如下:


<!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="https://www.jb51.net/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" /><span></span><br />
密码<input type="text" />
</div>
</body>
</html>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfwfjd.html