所以我的ajax成功功能没有加载。所以我不知道它有什么问题。有什么办法可以检查吗?和 mysql_error() 一样吗?现在,如果你们能弄清楚它有什么问题,或者另一端的 PHP 有什么问题,那就太好了。
jQuery.ajax({
type: "POST",
url: "http://mywebsite.net/snippetsave.php",
data: {id: snippetID, name: snippetName, content: snippetContent},
cache: false,
success: function(response){
loadsnippet(snippetID);
$("body").attr("saved", "yes");
$("a[snippetid='" + snippetID + "']").addClass("saved");
}
});
和片段保存.php:
<?php
session_start();
$username = $_SESSION['username'];
$password = $_SESSION['password'];
$connect = mysql_connect(......);
$select_db = mysql_select_db(.....);
if(!$connect){
die(mysql_error());
}
$currentsnippet = mysql_escape_string($_POST['id']);
$snippetnames = mysql_escape_string($_POST['name']);
$snippetcontents = mysql_escape_string($_POST['content']);
$update = mysql_query("UPDATE newsnippets SET name='$snippetnames', content='$snippetcontents' WHERE id='$currentsnippet'");
if (!$update){
die(mysql_error());
}
?>