0

我想通过单击按钮将数据保存在数据库中。这是我的代码,在 Firefox 中它不起作用,它显示空警报并且数据不保存在表中。

    $("#Save").click(function () {  
       var price = $("#price").val(); 
       var agent_1_id= $("#agent_1_id").val();
       var type = $("#type").val();
    $.post("ajax_files/myDeals.php",
             { 
              price: price,
              agent_1_id: agent_1_id,type:type
              },
            function(data) {
                alert(data);
      });           
});

单击事件触发并调用此函数。这是 myDeals.php 上保存在表中的代码..

$price = $_REQUEST['price']; 
$agent_1_id = $_REQUEST['agent_1_id'];
$type = $_REQUEST['type'];
mysql_query('insert query here');

echo "Saved Successfully ";//this is not alerted?
4

1 回答 1

0

尝试将数据作为对象发送的示例:

function end_incident() {
    $.ajax({
       type: "POST",
       url: "http://www.example.co.uk/erc/end_incident.php",
       data: { name: "Daniel", phone: "01234123456" },
       success: function(msg){ 
            alert('Success!');
       }
    });
};
于 2013-03-06T18:20:04.353 回答