weixin_33671935 2018-02-14 11:16 采纳率: 0%
浏览 39

Ajax表单没有$ _POST数据

I've been trying to get this Ajax form to work and I think i'm mostly there. Essentially, the concept is that a user can click "Add" and it submits the form and appends a new clone (with incrementing ID etc.) to the bottom, repeatable ad infinitum.

So, from what I can tell on my form it is correctly serialising the last form and is running through the query, Chromes network feature implies an array has been sent featuring the correct data to the page I'm wanting to send it to, but "$_POST" is not being set on the PHP end and I can't work out why.

Here is my script:

 <script type="text/javascript">
$("#form_button").click(function() {
 var formData = $("form:last").serialize();
  console.log(formData);
    $.ajax({
        type: "POST",
        url: 'Academic_Submit.php',
        data: formData,
    success: function(response, textStatus, jqXHR) {
   alert("Yay!");
 },
 error: function(jqXHR, textStatus, errorThrown){
  alert(textStatus, errorThrown);
    } 

  });
}); 
</script>

At the moment, I get "YAY" returned, implying it was success, so I'm not sure the issue is this end, Currently all my PHP file is doing is

<?php


 $arr = get_defined_vars();
 var_dump($arr);

 ?>

but I have tried print_r($_POST) to no luck. Can anybody shed any light on what could possibly be causing this, as I can't think of what else to try.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧