jquery和ajax传递参数到后台,后台插入数据库的值是空值
functionsendMessage(){varph=$("#phone").val();if(ph.length<1){alert("phone空值");return...
function sendMessage() {
var ph=$("#phone").val();
if(ph.length<1){alert("phone空值"); return false;}
$.ajax({
type: "POST", //用POST方式传输
dataType: "text", //数据格式:JSON
url: 'newuser2.php', //目标地址
data: 'phone=' + ph,
error: function () { alert('Error loading XML document'); },
success: function (msg){}
});
}
后台:
$mobile=$_POST['phone'];
//$mac=$_POST['ma'];
echo save($mobile,$mac);
function save($mobile){
$db_connect=mysql_connect(省略) or die("ERROR!");
mysql_select_db('wifi');
mysql_query("INSERT INTO u_info VALUES(NULL,NULL,NULL,'$moblie',NULL,NULL)");
return true;
}
求大神指点,初学者 展开
var ph=$("#phone").val();
if(ph.length<1){alert("phone空值"); return false;}
$.ajax({
type: "POST", //用POST方式传输
dataType: "text", //数据格式:JSON
url: 'newuser2.php', //目标地址
data: 'phone=' + ph,
error: function () { alert('Error loading XML document'); },
success: function (msg){}
});
}
后台:
$mobile=$_POST['phone'];
//$mac=$_POST['ma'];
echo save($mobile,$mac);
function save($mobile){
$db_connect=mysql_connect(省略) or die("ERROR!");
mysql_select_db('wifi');
mysql_query("INSERT INTO u_info VALUES(NULL,NULL,NULL,'$moblie',NULL,NULL)");
return true;
}
求大神指点,初学者 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询