我有一些jquery ajax代碼來更新記錄,但它不像預期的那樣工作。JQuery Ajax沒有更新記錄
下面是代碼:
function update_records() {
$.ajax({
type: "POST", // Set the type then $_GET['id'] or $_POST['id']
url: "update_record.php",
data: { category: "John", image: "Boston" }
}).done(function(msg) {
alert("Data Saved: " + msg);
});
}; //end function
Then the php
<?php
$id = $_REQUEST['id'];
include 'config.php';
$result = mysql_query("UPDATE mytable SET title = 'something' where id=$id");
$result = mysql_query("SELECT * FROM mytable WHERE id = '$id'");
$array = mysql_fetch_row($result);
?>
哪裏代碼休息的價值?成功函數是否被調用?如果你在瀏覽器中打開update_record.php會怎麼樣?你的HTML在哪裏? –