我成功从mysql数据库获取数据,直到我尝试删除表。该表下降,但我无法弄清楚如何保持javascript ajax数据库访问声明错误。
如果没有要返回的数据,我怎么能回来?
以下php例程删除订单表中的一行,然后删除名为$ tableNameInput的表。检查数据库显示两个操作都已成功执行但javascript ajax错误处理因x.status = 0而被触发。我只需要一种方法来告诉javascript ajax它是否真的完整。
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.*/
}
}
提前感谢您的帮助。
答案 0 :(得分:1)
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);/* .*/
}
问题是你正在丢弃表并返回结果if 它的真实和无视的错误
答案 1 :(得分:0)
问题不在于json回归。这是因为我没有成功回调ajax调用。