I encountered a problem at work today
The code is as follows:
var status=1;
var ob=$("[name='email']");
$.ajax({
url:"{:U('Home/Index/checkemail ')}",
data:"email=" query.email,
type:"post",
dataType:"json",
success:function(re){
status =0;
}
});
alert(status);
In this way, the value that pops up every time is 1;
Because we want to use the returned value Process and change status to its value, check some information
Solution: async:false,
rewritten as:
$.ajax({
async:false,
url:"{:U('Home/Index/checkemail')}",
data:"email=" query.email,
type:"post",
dataType:"json",
success:function(re){
status=0;
}
});