在POST模式下使用Ajax更新PHP中的MySQL表

时间:2015-07-02 14:51:16

标签: javascript php jquery ajax


我想做一个更新:

这是我的php页面中的js脚本:

            alert ("Ench : " + idE + " Price : "+ pf2 +" idU : " + idU); 
            $.ajax({
                url: './update.php', //same place in the server
                type : 'POST',
                data : 'id_enchere=' + idE + '&idU=' + idU + '&prix=' + pf2,
                dataType: 'html',
                success: function() {
                        return false;
                    }
            });

警告(..)确认我的值已填满。

这是我的PHP页面: update.php

$query=$db->prepare('UPDATE enchere SET id_membre_act = :idU, prix_actuel = :prix WHERE id = :id_enchere');
$query->bindValue(':id_enchere', $_POST['id_enchere'], PDO::PARAM_STR);
$query->bindValue(':idU', $_POST['idU'], PDO::PARAM_STR);
$query->bindValue(':prix', $_POST['prix'], PDO::PARAM_STR);
$query->execute();

我已经在我的数据库中选择并插入,因此连接良好。

我是php和js / ajax编程的新手 我不明白为什么它不起作用 我试着把它放在被调用的页面中:

$file = fopen('./files/test.txt', 'w+'); 

并且没有创建文件。所以我认为我的页面没有被调用。

感谢您的帮助。

纪尧姆。

0 个答案:

没有答案