62,074
社区成员
发帖
与我相关
我的任务
分享
$(document).ready(function () {
$("#huiyuan_login").click(function () {
var username = $("#username").val();
var password = $("#password").val();
var isVailid = true;
if (username.length <= 0) {
alert("会员名不能为空!");
$("#username").focus();
isVailid = false;
return false;
} if (password.length <= 0) {
alert("密码不能为空!");
$("#password").focus();
isVailid = false;
return false;
}
///////
if (isVailid) {
$.ajax({
type: "post",
url: "",
data: { username: $("#username").val(), password: $("#password").val() },
beforeSend: function () { $("#messages").html("logining"); },
success: function (data) {
$("#messages").html(decodeURI(data));
}
});
}
});
});
/// <summary>
/// 获取URL
/// </summary>
/// <returns></returns>
public string stringUrl()
{
return Request.Url.ToString();
}
$("#huiyuan_login").click(function () {
var username = $("#username").val();
var password = $("#password").val();
var stringUrl=$("#stringUrl").val();
alert(stringUrl);
var isVailid = true;
if (username.length <= 0) {
alert("会员名不能为空!");
$("#username").focus();
isVailid = false;
return false;
} if (password.length <= 0) {
alert("密码不能为空!");
$("#password").focus();
isVailid = false;
return false;
}
///////
if (isVailid) {
$.ajax({
type: "post",
url:"",
data: { username: $("#username").val(), password: $("#password").val() },
beforeSend: function () { $("#messages").html("logining"); },
success: function (data) {
$("#messages").html(decodeURI(data));
}
});
}
});
if (isVailid) {
$.ajax({
// contentType: "application/jo; charset=utf-8",
// dataType: "text",
type: "post",
url: location.href,
data: { username: $("#username").val(), password: $("#password").val() },
// data: "{username:'" + $("#username").val() + "',password:'" + $("#password").val() + "'}",
beforeSend: function () { $("#messages").html("正在登陆,请稍后....."); },
success: function (data) {
// // alert(data);
// // var obj = eval("(" + data + ")");
// var obj = JSON.parse(data);
var dataObj = eval("(" + data + ")"); //转换为json对象
alert(dataObj);
}
});
}
});
if (IsPostBack)
{
if (!string.IsNullOrEmpty(Request["username"]) && !string.IsNullOrEmpty(Request["password"]))
{
string IsValidate = "false"; //检测是否有用户
string username = Common.FilteStr(Request["username"].ToString());
string password = Common.FilteStr(Request["password"].ToString());
string sql = "select * from userinfo where username='" + username + "' and newPassword='" + password + "'";
DataTable dt = Common.GetTable(sql);
if (dt.Rows.Count > 0)
{
IsValidate = "true";
}
else
{
IsValidate = "false";
}
//////不让浏览器使用缓存
Response.ContentType = "text/plain";
//Response.Buffer = true;
//Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
//Response.AddHeader("pragma", "no-cache");
//Response.AddHeader("cache-control", "");
//Response.CacheControl = "no-cache";
//Response.Clear();
//Response.ClearHeaders();
//Response.Write(IsValidate);
//Response.Flush();
//Response.Close();
//Response.Clear();
//Response.Write("'" + IsValidate + "'");
//Response.End();
Response.Write(IsValidate);
// Response.Flush();
Response.End();
}
else
{
Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('用户名和密码都不能为空');</script>");
}
}