e.preventDefault / return false会中断正确的ajax脚本

I'm creating an ajax script to update a few fields in the database. I got it to a point where it worked but it sent the user to the php script instead of staying on the page so I did some googling, and people suggested using either return false; or e.preventDefault() however, if I do this, it breaks the php script on the other page and returns a fatal error. I might be missing something being newish to AJAX but it all looks right to me

JS:

$(document).ready(function() {
    var form    = $('form#edit_child_form'),
        data    = form.serializeArray();

    data.push({'parent_id': $('input[name="parent_id"]').val()});

    $('#submit_btn').on('click', function(e) {
        e.preventDefault();
        $.ajax({
            url:      form.prop('action'),
            dataType: 'json',
            type:     'post',
            data:     data,
            success: function(data) {
                if (data.success) {
                    window.opener.$.growlUI(data.msg);
                }
            },
            error: function(data) {
                if (!data.success) {
                    window.opener.$.growlUI(data.msg);
                }
            }
        });
    });
})

AJAX:

<?php
    //mysql db vars here (removed on SO)


    $descriptions = $_GET['descriptions'];
    $child_id     = $_GET['child_id'];
    $parent_id    = $_GET['parent_id'];

    $get_child_ids = $dbi->query("SELECT child_ids FROM ids WHERE parent = ". $parent_id ." ORDER BY id"); //returns as object
    $count         = 0;
    $res           = array();

    while ($child_row = $get_child_ids->fetch_row())
    {
        try
        {
            $dbi->query("UPDATE ids SET description = '$descriptions[$count]', child_id = '$child_id[$count]' WHERE parent_id = $child_row[0]");

            $res['success'] = true;
            $res['msg']     = 'Success! DDI(s) updated';
        } catch (Exception $e) {
            $res['success'] = true;
            $res['msg']     = 'Error! '. $e->getMessage();
        }

        $count++;
    }

    echo json_encode($res);

it's probably something really small that I've just missed but not sure what - any ideas?

my solution:

I var_dumped $_GET and it returned null - changed to $_REQUEST and it got my data so all good :) thanks for suggestions

Try the following instead.
I moved the form data inside click and enclosed the mysql queries values in single quotes.

JS:

$(document).ready(function() {
    var form    = $('form#edit_child_form');

    $('#submit_btn').on('click', function(e) {
        e.preventDefault();
       var  data    = form.serializeArray();

       data.push({'parent_id': $('input[name="parent_id"]').val()});

        $.ajax({
            url:      form.prop('action'),
            dataType: 'json',
            type:     'get',
            data:     data,
            success: function(data) {
                if (data.success) {
                    window.opener.$.growlUI(data.msg);
                }
            },
            error: function(data) {
                if (!data.success) {
                    window.opener.$.growlUI(data.msg);
                }
            }
        });
    });
})

AJAX:

<?php
    //mysql db vars here (removed on SO)


    $descriptions = $_GET['descriptions'];
    $child_id     = $_GET['child_id'];
    $parent_id    = $_GET['parent_id'];

    $get_child_ids = $dbi->query("SELECT child_ids FROM ids WHERE parent = '". $parent_id ."' ORDER BY id"); //returns as object
    $count         = 0;
    $res           = array();

    while ($child_row = $get_child_ids->fetch_row())
    {
        try
        {
            $dbi->query("UPDATE ids SET description = '$descriptions[$count]', child_id = '$child_id[$count]' WHERE parent_id = '$child_row[0]'");

            $res['success'] = true;
            $res['msg']     = 'Success! DDI(s) updated';
        } catch (Exception $e) {
            $res['success'] = true;
            $res['msg']     = 'Error! '. $e->getMessage();
        }

        $count++;
    }

    echo json_encode($res);

You are using an AJAX POST request so in your PHP you should be using $_POST and not $_GET.

You can just change this:

$descriptions = $_GET['descriptions'];
$child_id     = $_GET['child_id'];
$parent_id    = $_GET['parent_id'];

to this:

$descriptions = $_POST['descriptions'];
$child_id     = $_POST['child_id'];
$parent_id    = $_POST['parent_id'];