PHP脚本中未定义Jquery ajax参数

I'm using jQuery Ajax to send parameters to a PHP script. Below is the Jquery ajax script

  jQuery
<script>
$(document).ready(function () {
    $("#builder_group").change(function () {
        var selected_builder = $(this).val();
        alert(selected_builder);
        $.ajax({
            type: 'POST',
            url: 'getGroupzCode.php',
            data: 'selected_builder',
            datatype: 'json',
            success: function (data) {
                // Call this function on success                
                console.log(data);
                var yourArray = JSON.parse(data);
                console.log(yourArray);
                $.each(yourArray, function (index, yourArray) {
                    $('#builder_group1').append($('<option/>', {
                        value: yourArray.id,
                        text: yourArray.name,
                    }));
                });
            },
            error: function () {
                displayDialogBox('Error', err.toString());
            }
        });
    });
});
</script>

When I see in firebug console I see the parametr passed is correct as selected but in the PHP script I see undefined index

PHP
    $builder_id=$_POST['selected_builder'];
    error_log($builder_id);
data: 'selected_builder',

That is not proper format. You need:

data: { selected_builder: selected_builder }

The below indicates you're receiving a json, is that correct? If so the parameter is "dataType" like below.

dataType: 'json',

If so you are you would use this in your php file:

$encoded = json_encode($yourvariable);
echo $encoded;

Now if this wasn't the case you would call the variable in php by:

$variable = $_POST["selected_builder"];