Javascript php在成功删除我的表后返回错误
在尝试删除表之前,我一直在成功地从mysql数据库获取数据。该表将被删除,但我不知道如何防止javascript ajax数据库访问声明错误 没有数据可返回时,如何返回ok 下面的php例程删除order表中的一行,然后删除名为$tableNameInput的表。对数据库的检查表明,这两个操作都已成功执行,但javascript ajax错误处理会在x.status=0时中断。我只需要一种方法来告诉javascript ajax它真的完成了Javascript php在成功删除我的表后返回错误,javascript,php,ajax,Javascript,Php,Ajax,在尝试删除表之前,我一直在成功地从mysql数据库获取数据。该表将被删除,但我不知道如何防止javascript ajax数据库访问声明错误 没有数据可返回时,如何返回ok 下面的php例程删除order表中的一行,然后删除名为$tableNameInput的表。对数据库的检查表明,这两个操作都已成功执行,但javascript ajax错误处理会在x.status=0时中断。我只需要一种方法来告诉javascript ajax它真的完成了 function dropCartTable($tab
function dropCartTable($tableNameInput){/* drops the cart table and its order entry*/
AnnLog("dropCartTable: ",$tableNameInput);
// first drop the reference in the orders table
$tableName = "orders";
$query = "DELETE FROM $tableName WHERE cartDB ='$tableNameInput'";
$result = doQuery($tableName,$query, "Could not drop orders row");
if($result){
// now drop this cart table
$sql = "DROP TABLE IF EXISTS $tableNameInput";
}
//********do query just does the query and logs. it does not return if it dies.
$result = doQuery($tableName, $sql, "Can not drop csrt table");
if($result){
/****** when we get to here we have successfully dropped the items. below, I tried to generate a response and it did not work.*/
$arr = array('drop cart' => 0);
$j = json_encode ($arr);
echo \json_encode($j);
AnnLog("echoed ",$j);/* this writes my logs which verify that all steps until the return are ok.*/
}
}
提前感谢你的帮助
function dropCartTable($tableNameInput){/* drops the cart table and its order entry*/
AnnLog("dropCartTable: ",$tableNameInput);
// first drop the reference in the orders table
$tableName = "orders";
$query = "DELETE FROM $tableName WHERE cartDB ='$tableNameInput'";
$result = doQuery($tableName,$query, "Could not drop orders row");
if($result)
{
// now drop this cart table
$sql = "DROP TABLE IF EXISTS $tableNameInput";
$arr = array('drop cart' => 0);
$j = json_encode ($arr);
echo \json_encode($j);
AnnLog("echoed ",$j);/* this writes my logs which verify that all steps until the return are ok.*/
}
else
{
$arr = array("couldn't drop cart" => 0);
$j = json_encode ($arr);
echo \json_encode($j);
AnnLog("echoed ",$j);/* .*/
}
问题是您正在删除表并在
是真是假
问题不在json返回中。这是由于我没有成功回调ajax调用造成的 你是双重编码你的JSON为什么不只是
echo JSON_encode($arr)代码>?不知怎的,上面的一些行被删除了。实际上有两个查询,一个查询到订单表,另一个查询到购物车表。在这两种情况下,我都调用一个名为doquery的函数,该函数处理查询并将日志记录到我的日志文件中。如果查询失败,日志文件将更新,进程将终止。if($结果是rednundant。我的问题是json_编码没有返回到调用的rountine。我得到错误号0。格式错误。我们如何关闭它?