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条回答 默认 最新

    报告相同问题?