多次Ajax提交数据,SQL语句不能全部执行

浏览:1358 发布日期:2015/01/23 分类:求助交流 关键字: Ajax提交 多次执行

在页面多次提交Ajax请求,发现不能完全执行。
版本: TP3.2.3
PHP:5.6
数据库:Mysql5.6
WEB: Apache2.4
使用插件:
zTree3.5
Bootstrap 3.0



控制器代码: public function moveDepotKind() {
        $response = array('status' => 0, 'info' => L('UNKNOWN_ERROR'));
        if (IS_AJAX) {
            $id = I('post.id/d', 0); // 被移动节点ID
            $new_num = I('post.num/d', 0); // 新位置索引号
            $new_pid = I('post.pid/d', 0); // 新父ID
            //
            $model = M();
            // IN `in_id` int,IN `in_parentID` int,IN `in_num` int,OUT `out_code` int
            // 执行存储过程
            $sql = "call adjustCategoryPosition($id,$new_pid,$new_num, @out_code) ;";
            if ($model->execute($sql) === FALSE) { // 执行失败 
                $response = array('status' => 0, 'info' => $model->getDbError());
            } else {
                // 检查执行是否出现错误
             //   $info = \R('Index/get_procedure_error');
                $info = $this->get_procedure_error();
                 if ($info['Code'] === 0) {
                      $response = array('status' => 1, 'info' => '');
                 }else{
                    $response = array('status' => 0, 'info' => 'Error Code:' . $info['Code'] . '<BR>Message: ' . $info['Message'] );
                       // $response = $info;
                 }
            }
        } else {
            $response = array('status' => 0, 'info' => L('SUBMIT_TYPE_ERROR'));
        }
        $this->ajaxReturn($response);
    }
JS代码:function onDrop(event, treeId, treeNodes, targetNode, moveType, isCopy) {
                var node = zTree.getNodeByParam('id', treeNodes[0].id);
                var parentID = -1, num = -1; 
                switch (moveType) {
                    case 'inner':
                        parentID = targetNode.id;
                        num = zTree.getNodesByParam('parent_id', targetNode.id, targetNode).length;
                        break;
                    case 'prev':
                        parentID = targetNode.parent_id;
                        num = zTree.getNodeIndex(targetNode) - 1;
                        break;
                    case 'next':
                        parentID = targetNode.parent_id;
                        num = zTree.getNodeIndex(targetNode) + 1;
                        break;
                    default :
                        parentID = -1;
                }
                if (parentID < 0)
                    return;
                // 
                 $.post('{:U("Depot/moveDepotKind")}', {id: node.id, pid: parentID, num: num}, function (data) {
                 if (!data.status) {
                 BootstrapDialog.alert(data.info);
                 }else{
                      BootstrapDialog.alert('操作成功完成!');
                 } 
                 }, 'json'); 
            }
说明:
1、以上语句,没有发现错误。
2、在进行zTree的节点拖动时,进行Ajax提交,如果每次拖动一个,语句成功执行;如果拖动多个,则仅有个别的Ajax正确完成。
最佳答案
评论( 相关
后面还有条评论,点击查看>>