Php 如何检查jQueryAjax的错误?
所以我的ajax成功函数没有加载。所以我不知道它出了什么问题。我能查一下吗?就像mysql_error()一样?现在,如果你们能找出它的错误,或者是另一端的PHP,那就太好了Php 如何检查jQueryAjax的错误?,php,jquery,mysql,ajax,Php,Jquery,Mysql,Ajax,所以我的ajax成功函数没有加载。所以我不知道它出了什么问题。我能查一下吗?就像mysql_error()一样?现在,如果你们能找出它的错误,或者是另一端的PHP,那就太好了 jQuery.ajax({ type: "POST", url: "http://mywebsite.net/snippetsave.php", data: {id: snippetID, name: snippetName, content: snippetContent}, cache: fal
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");
}
});
和snippetsave.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());
}
?>
尝试添加错误处理程序函数:
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");
},
error: function(response) {console.log(response);}
});
可以在jQuery.ajax方法中添加回调方法
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");
},
error:function(){
// error handler
}
});
:==>:)
&+我不是投票人!玩得开心#还请阅读有关单一原产地政策和CORS的内容!已经回答了,但是谢谢:)顺便说一句,人们对看似愚蠢的问题投反对票是正常的吗?比如,我觉得这个网站也不是那么有经验的人。这不是一个完全可以接受的问题吗?