weixin_33739523 2013-02-07 02:40 采纳率: 0%
浏览 25

jQuery AJAX脚本未触发

I have the following AJAX script which doesn't seem to be firing. Can anybody please tell me what's wrong with it?

form.php

<script type = "text/javascript"> $(document).ready(function () {
    $('#updatebtn1').click(function () {
        $('#result1').show('slow').delay(4000).hide('slow')
        $.post('process.php', $('#updateform1').serialize())
    });
});
</script>

<form id="updateform1">
    <div class="tbl_header">Timetable Support Website</div>Due Date:
    <script>
        $(function() {
            $("#datepicker1").datepicker({
                minDate: -0,
                dateFormat: 'dd/mm/yy',
                maxDate: new Date(2013, 1, 22)
            })
        });
    </script>
    <input type="text" id="datepicker1" style="width: 100px;
            height: 10px;" value="18/02/2013" name="duedate" />&nbsp; Status:
    <select style="width: 125px;" name="status">
        <option>Pending</option>
        <option>----</option>
        <option>Pending</option>
        <option>In Progress</option>
        <option>Complete</option>
    </select>&nbsp;
    <input type="hidden" name="id" value="1">
    <input type="button" id="updatebtn1" value="Update" style="width: 100px;"
    class="pmbtn" />
</form>
<div id="result1" style="display: none; color: red">Update successful!</div>

process.php

<?php
$duedate = $_POST["duedate"];
$status = $_POST["status"];
$id = $_POST["id"];

$sql = "UPDATE pm_schedule SET duedate=?, status=?, id=? WHERE id=?";
$q = $pdo->prepare($sql);
$q->execute(array($duedate,$status,$id));
?>
  • 写回答

1条回答 默认 最新

  • ℙℕℤℝ 2013-02-07 02:54
    关注

    I'm not overly familiar with positional place holders (I always used named place holders), but I'm assuming you need to do

    $q->execute(array($duedate,$status,$id,$id)); 
    

    since $id is used twice. MySQL doesn't know what you want for the final place holder. It's likely throwing some sort of error that the place holder count doesn't match.

    Try adding this to your database handle:

    $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
    

    and then echoing the output of process.php back to the main page.

    评论

报告相同问题?

悬赏问题

  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?