dsqbh42082 2015-11-16 10:58
浏览 36

jquery ajax发布失败,未返回错误

ive read some questions related to my question but i can't find a solution

in some part of my website. posting a single value to a php page works

so i searched passing multiple values using ajax and applied it to my website but i says posting failed

this is the php code. i tried running it to my server by passing directly a data to the php and it works like this $temp1 = "0001" this is the inserdocument.php file

$temp1 = $_POST['dtnum'];
$temp2 = $_POST['ddoctitle'];
$temp3 = $_POST['ddoctype'];
$temp4 = $_POST['ddoccontent'];
$temp5 = $_POST['ddocdatefilled'];
$stmt = $conn->prepare("CALL sp_insertdocument (?,?,?,?,?)");
$stmt->bindParam(1, $temp1, PDO::PARAM_STR, 30); 
$stmt->bindParam(2, $temp2, PDO::PARAM_STR, 50); 
$stmt->bindParam(3, $temp3, PDO::PARAM_STR, 50); 
$stmt->bindParam(4, $temp4, PDO::PARAM_STR, 10); 
$stmt->bindParam(5, $temp5, PDO::PARAM_STR, 10); 
$stmt->execute(); 

and this is my ajax code. i even tried adding try and catch but the catch returns nothing.

    $.ajax({
                type: "POST",
                url: "inserdocument.php",
                data: ({dtnum: tnum, ddoctitle: doctitle, ddoctype: doctype, ddoccontent: doccontent, ddocdatefilled: docdatefilled})
            })
            .done(function (msg) {
                alert("Data Saved: " + msg);

        //$('#response').html(msg);
            })
    .fail(function() {
        alert( "Posting failed." );
    });
  • 写回答

1条回答 默认 最新

  • download201401 2015-11-16 11:38
    关注

    im sorry for posting i found out that the problem is here url: "inserdocument.php" it should be url: "insertdocument.php"

    typographical error. im concentrating at the passing of data, i didn't notice the php filename is incorrect. sorry

    评论

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析