日期:2014-05-16 浏览次数:20710 次
<script type="text/javascript">
$(document).ready(function () {
$("#username").blur(function () {
var name = document.getElementById("username").value;
var theName = escape(name);
$.post("A2.ashx", { username: theName },
function (data) {
alert(data);
});
});
});
</script>
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string name = context.Request.QueryString["username"];
string result = "denied";
if (name == "t")
{
result = "okay";
}
context.Response.Write(result);
}
$(document).ready(function () {
$("#username").blur(function () {
var name = document.getElementById("username").value;
//var theName = escape(name);//这里不用编码了,指定数据为json对象jq会自动调用encodeURIComponent帮你编码的
$.post("A2.ashx", { username: theName },
function (data) {
alert(data);
});
});
});