csdn产品小助手 2010-02-18 20:24 采纳率: 0%
浏览 12

jQuery Ajax发布错误的数据

I have a a form:

<form id="deletesubmit" style="display:inline" >
    <input  style="width:50px" type="text" id="delcustomerid" name="delcustomerid" value="'.$row['customersid'].'">
    <button type="submit" class="table-button ui-state-default ui-corner-all" title="delete"><span class="ui-icon ui-icon-trash"></span></button>
</form>

The form gets the customers id and inserts it as value. It shows the correct customer is for that row everything is fine. Then when i post the form via ajax somehow it posts the id of a diffent row. This is the script:

$("form#deletesubmit").submit(function () {

    var delcustomerid = $('#delcustomerid').attr('value');
    $.ajax({
        type: "POST",
        url: "delete/process.php",
        data: "delcustomerid=" + delcustomerid,
        success: refreshTable
    });
    return false;
});
});

And finally here is the php to post the form:

<?php include("../../config/config.php"); ?>
<?php          
    $deleteid  = htmlspecialchars(trim($_POST['delcustomerid']));
    mysql_send("DELETE FROM customers where id='$deleteid'");
?>

I have tested it without the ajax and it works fine. There must be something missing. It is not posting the correct value. Spent days trying to work it out.

  • 写回答

3条回答 默认 最新

  • Didn"t forge 2010-02-18 20:27
    关注

    Put an alert into the code prior to the $.ajax({ like so:

    alert(delcustomerid);
    

    Is the value wrong right before the post?

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器