刘凝之字志安翻译:ajax使用流程【ajax详细使用步骤、ajax使用实例】
来源:百度文库 编辑:中财网 时间:2024/05/06 16:29:22
1、js方法
width="138" height="40" />
2、添加js方法
function createuser() {
if ($("#emailinfo").html().indexOf("Email地址合法") == -1) {
checkregemail();
changeimg();
return false;
}
if ($("#spanRegtype").val() == "1") {
if ($("#mobileInfo").html().indexOf("手机号合法") == -1) {
checkregMobile();
changeimg();
return false;
}
}
if ($("#repasswordinfo").html().indexOf("密码输入合法") == -1) {
recheckpassword();
changeimg();
return false;
}
if ($("#validateinfo").html().indexOf('验证码输入正确') == -1) {
checkvalidecode();
changeimg();
return false;
}
var $bday = "NULL";
var $mobile = $("#txtMobile").val();
var $cardid = $("#year").val();
var $answer = $("#txtanswer").val();
//开始注册用户
get传参:
$.ajax({//ajax调用传参
url: "/ajax.aspx?q=createuser&email=" + $("#txtemail").val() + "&mobile=" + $mobile + "&password=" + $("#txtpassword").val() + rand(100000, 999999) + "®type=" + $("#spanRegtype").val() + "&cardid=" + $cardid + "&answer=" + encodeURIComponent($answer) + "&time=" + new Date().toString(),
type: "GET",
timeout: 30000,
beforeSend: function() {
$('#status').html("正在注册中...");
},
error: function() {
$("#status").addClass("redr");
$("#status").html("注册用户失败,请重试或联系管理员!");
},
success: function() {
var $status = arguments[0]; //得到返回值
if ($status > 0) {
window.location = ($("#referurl").val());
}
else {
$("#status").addClass("redr");
$("#status").html("注册成功");
alert("注册成功");
window.location = $("#fromurl").val();
}
}
});
post传参:
$.ajax({
url: "/ajax.aspx?",
data: {
"q": "saveAddSKU",
"eid": eid,
"skulist": skulist,
"skunum": skunum,
"skupic": skupic,
"picbs": picbs,
"skupicnum": skupicnum,
"time": new Date().toString()
},
type: "POST",
timeout: 50000,
beforeSend: function() {
},
error: function() {
alert("SKU追加失败");
},
success: function(res) {
if (res == "0") {
alert("SKU追加成功");
}
}
});
}
3、ajax方法
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
switch (q)
{
#region 根据参数不同,进行不同的操作
case "checkemail"://检测邮箱是否可用
checkRegInfo(0);
break;
case "checkloginname"://检测用户名是否可用
checkRegInfo(1);
break;
case "checkmobile"://检测手机号是否可用
checkRegInfo(2);
break;
case "createuser"://注册用户
createuser();
break;
#endregion
}
}
}
#region 注册用户 对数据进行添加
private void createuser()
{//调用存储过程实例
string email = Fetch.Get("email"); //Fetch 分装类
string password = Fetch.Get("password");
string mobile = Fetch.Get("mobile");
string temp = password.Substring(0, password.Length - 6);
int regfrom = 0;
string question = Fetch.Get("cardid");
string rettype = Fetch.Get("regtype");
string answer = Fetch.Get("answer");
string userip = Page.Request.UserHostAddress;
int result = 0;
string msg = string.Empty;
iuser.regUser("", temp, rettype, mobile, email, regfrom, userip, question, answer, out result, out msg);
string itemp = result.ToString() + "@" + msg;
password = password.Substring(0, 6);
password = Common.Text.MD5(password);
DataSet ds = iuser.sp_login(email, password, Fetch.UserIp, out result, out msg);
if (ds != null && ds.Tables.Count > 0)
{
DataTable dt = ds.Tables[0];
commonfunction.SaveLoginCookie(dt.Rows[0]);
}
Response.Write(itemp); //打印返回值
Response.End();
}
#endregion
width="138" height="40" />
2、添加js方法
function createuser() {
if ($("#emailinfo").html().indexOf("Email地址合法") == -1) {
checkregemail();
changeimg();
return false;
}
if ($("#spanRegtype").val() == "1") {
if ($("#mobileInfo").html().indexOf("手机号合法") == -1) {
checkregMobile();
changeimg();
return false;
}
}
if ($("#repasswordinfo").html().indexOf("密码输入合法") == -1) {
recheckpassword();
changeimg();
return false;
}
if ($("#validateinfo").html().indexOf('验证码输入正确') == -1) {
checkvalidecode();
changeimg();
return false;
}
var $bday = "NULL";
var $mobile = $("#txtMobile").val();
var $cardid = $("#year").val();
var $answer = $("#txtanswer").val();
//开始注册用户
get传参:
$.ajax({//ajax调用传参
url: "/ajax.aspx?q=createuser&email=" + $("#txtemail").val() + "&mobile=" + $mobile + "&password=" + $("#txtpassword").val() + rand(100000, 999999) + "®type=" + $("#spanRegtype").val() + "&cardid=" + $cardid + "&answer=" + encodeURIComponent($answer) + "&time=" + new Date().toString(),
type: "GET",
timeout: 30000,
beforeSend: function() {
$('#status').html("正在注册中...");
},
error: function() {
$("#status").addClass("redr");
$("#status").html("注册用户失败,请重试或联系管理员!");
},
success: function() {
var $status = arguments[0]; //得到返回值
if ($status > 0) {
window.location = ($("#referurl").val());
}
else {
$("#status").addClass("redr");
$("#status").html("注册成功");
alert("注册成功");
window.location = $("#fromurl").val();
}
}
});
post传参:
$.ajax({
url: "/ajax.aspx?",
data: {
"q": "saveAddSKU",
"eid": eid,
"skulist": skulist,
"skunum": skunum,
"skupic": skupic,
"picbs": picbs,
"skupicnum": skupicnum,
"time": new Date().toString()
},
type: "POST",
timeout: 50000,
beforeSend: function() {
},
error: function() {
alert("SKU追加失败");
},
success: function(res) {
if (res == "0") {
alert("SKU追加成功");
}
}
});
}
3、ajax方法
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
switch (q)
{
#region 根据参数不同,进行不同的操作
case "checkemail"://检测邮箱是否可用
checkRegInfo(0);
break;
case "checkloginname"://检测用户名是否可用
checkRegInfo(1);
break;
case "checkmobile"://检测手机号是否可用
checkRegInfo(2);
break;
case "createuser"://注册用户
createuser();
break;
#endregion
}
}
}
#region 注册用户 对数据进行添加
private void createuser()
{//调用存储过程实例
string email = Fetch.Get("email"); //Fetch 分装类
string password = Fetch.Get("password");
string mobile = Fetch.Get("mobile");
string temp = password.Substring(0, password.Length - 6);
int regfrom = 0;
string question = Fetch.Get("cardid");
string rettype = Fetch.Get("regtype");
string answer = Fetch.Get("answer");
string userip = Page.Request.UserHostAddress;
int result = 0;
string msg = string.Empty;
iuser.regUser("", temp, rettype, mobile, email, regfrom, userip, question, answer, out result, out msg);
string itemp = result.ToString() + "@" + msg;
password = password.Substring(0, 6);
password = Common.Text.MD5(password);
DataSet ds = iuser.sp_login(email, password, Fetch.UserIp, out result, out msg);
if (ds != null && ds.Tables.Count > 0)
{
DataTable dt = ds.Tables[0];
commonfunction.SaveLoginCookie(dt.Rows[0]);
}
Response.Write(itemp); //打印返回值
Response.End();
}
#endregion
谁知道Google的AJAX开发工具GWT怎样使用??
使用ajax.net框架如何对.net控件赋值?
什么是ajax
什么是Ajax
AJAX 代码
什么是 ajax
AJAX是什么意思?
AJAX是什么?
讨论一下ajax
Ajax技术
什么是Ajax?
AJAX是什么?
什么是AJAX?
ajax问题
在IE中使用ajax,更新页面节点后IE中没有显示,是什么原因呢?
遇到了一个很奇怪的问题ajax+asp.net(c#)在使用access数据库的时候.
传真机的详细使用步骤?
CutFtp的详细使用步骤
CutFtp的详细使用步骤
CutFtp的详细使用步骤
CutFtp的详细使用步骤
CutFtp的详细使用步骤
CutFtp的详细使用步骤
关于AJ 和 AJAX