我需要在ajax的sert数据中,我有两个页面,一次是带有图标的表单,我点击它并将我发送到其他页面并插入新数据
这里是ajax代码
<script type="text/javascript">
$(function() {
$("#dialog1").click(function() {
$('#welcome').slideToggle('#loginhandle');
$('#loginhandle').show("slow");
var name = $("input#ausers_ID").val();
var dataString = 'ausers_ID='+ ausers_ID ;
$.ajax({
type: "POST",
url: "OpenCashier.php",
data: dataString,
success: function(msg) {
$('#loginhandle').slideToggle('#msgreturn');
$('#msgreturn').show("slow");
$('#msgreturn').html(msg)
.hide()
.fadeIn(1500, function() {
});
}
});
return false;
});
});
</script>
当我点击此底部
<input type="submit" id="dialog1" name="dialog1" value="Insert" />
我们必须调用此页面
<? session_start();
include("sec.php");
include("../include/connect.php");
include("../include/safe.php");
if($_POST["dialog1"]){
// Every thing is OK
$ausers_ID=$_POST["ausers_ID"];
$cashiers_CashierOpenDate=date('Y/m/d');
$query="INSERT INTO `cashiers` ( `cashiers_CashierID` , `cashiers_CashierOpenDate` , `cashiers_User` , `cashiers_Status` , `cashiers_Delete` ) VALUES ('', '$cashiers_CashierOpenDate', '$ausers_ID', '0','0');";
mysql_query($query);
$num=mysql_affected_rows();
if($num==1)
$message="Account was added successfully";
else
$message=$_POST["dialog1"]." Account is already exists in database";
}
?>
但数据无法插入原因!!!
答案 0 :(得分:0)
您错过了包含PHP代码中使用的“dialog1”参数。
我建议将您的数据更改为发送至:
var dataString = {ausers_ID : ausers_ID, dialog1 : true}