function test_pro(channel_id,province_able){
$.ajax({ type: "POST",
cache: "false",
url: "ajax_pro",
data: "channel_id=" + channel_id+"&province_able="+province_able,
dataType: "text",
error: function () {
$("#msg").html(" 请求失败!"); },
success:
function(message){
if(message=="false"){
document.getElementById("msg").innerHTML="<font color='red' size='2'>此省份已被使用</font>"
return false;
}else{
document.getElementById("msg").innerHTML="<font color='green' size='2'>可以使用</font>"
return true;
}
}
});
} 调用test_pro(channel_id,province_able)返回未定义!!!
$.ajax({ type: "POST",
cache: "false",
url: "ajax_pro",
data: "channel_id=" + channel_id+"&province_able="+province_able,
dataType: "text",
error: function () {
$("#msg").html(" 请求失败!"); },
success:
function(message){
if(message=="false"){
document.getElementById("msg").innerHTML="<font color='red' size='2'>此省份已被使用</font>"
return false;
}else{
document.getElementById("msg").innerHTML="<font color='green' size='2'>可以使用</font>"
return true;
}
}
});
} 调用test_pro(channel_id,province_able)返回未定义!!!
function test_pro(channel_id,province_able){
var result;
$.ajax({ type: "POST",
cache: "false",
url: "ajax_pro",
data: "channel_id=" + channel_id+"&province_able="+province_able,
dataType: "text",
error: function () {
$("#msg").html(" 请求失败!"); },
success:
function(message){
if(message=="false"){
document.getElementById("msg").innerHTML="<font color='red' size='2'>此省份已被使用</font>"
result = false;
}else{
document.getElementById("msg").innerHTML="<font color='green' size='2'>可以使用</font>"
result = true;
}
}
});return result;
}试一下
后改变result的值
jquery设置async:false,试一下