jquery 的ajax参数传不过去
js如下:<scripttype="text/javascript">functioncheckNumberExist(obj,async){if(typeof(asyn...
js如下:
<script type="text/javascript">
function checkNumberExist(obj,async) {
if (typeof(async) == "undefined") async = true;
var m = $.trim(obj.val());
var b = false;
$.ajax({
type: "POST",
async: async,
url: "/ajax/member/isNumberExist/" ,
date: 'number_id='+m,
dataType: "script",
success: function(data) {
if(data == 1) {
$("#"+obj.attr("name")).text('对不起,证件号码已注册。').css("color", "#ff0000");
b = false;
} else {
$("#"+obj.attr("name")).text('恭喜您,可以继续开立优惠账户。').css("color", "#000000");
b = true;
}
}
});
return b ;
}
</script>
接收端如下:
function isNumberExist() {
$number=$_POST['number_id'];
if (trim($number) != '') {
$query = $this->db->get_where('members', array('id_number ' => $number,'status' => 'succeed'));
echo $query->num_rows();
} else {
echo 'error';
}
}
无论我输入什么值,它都返回error,这应该是没有接收到'number_id',不知道问题出在哪里?请指点! 展开
<script type="text/javascript">
function checkNumberExist(obj,async) {
if (typeof(async) == "undefined") async = true;
var m = $.trim(obj.val());
var b = false;
$.ajax({
type: "POST",
async: async,
url: "/ajax/member/isNumberExist/" ,
date: 'number_id='+m,
dataType: "script",
success: function(data) {
if(data == 1) {
$("#"+obj.attr("name")).text('对不起,证件号码已注册。').css("color", "#ff0000");
b = false;
} else {
$("#"+obj.attr("name")).text('恭喜您,可以继续开立优惠账户。').css("color", "#000000");
b = true;
}
}
});
return b ;
}
</script>
接收端如下:
function isNumberExist() {
$number=$_POST['number_id'];
if (trim($number) != '') {
$query = $this->db->get_where('members', array('id_number ' => $number,'status' => 'succeed'));
echo $query->num_rows();
} else {
echo 'error';
}
}
无论我输入什么值,它都返回error,这应该是没有接收到'number_id',不知道问题出在哪里?请指点! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询