JavaScript问题

how i can add this variables to the code above? i need to pass these two variables. I tried but the code doesn't work as i expect (alerts doesn't working with the alterations).

        name: $('#name').val(),
        email: $('#email').val()


<script type="text/javascript">
    jQuery(document).ready(function() {
        $.ajax("valid.php", {
            type: "POST",
            dataType: "json",
            name: $('#name').val(), //here??
            email: $('#email').val() //here??
            success: function(step) {

                if (step.first) {
                    alert("fdsgdfg");
                }
                if (step.second) {
                    alert("dfgdfg");
                }

            }
        });
    });
</script>

thanks!

Add another part to your ajax call called "data".

<script type="text/javascript">
jQuery(document).ready(function() {
    $.ajax("valid.php", {
        type: "POST",
        dataType: "json",
        data: { name: $('#name').val(), email: $('#email').val() },
        success: function(step) {

            if (step.first) {
                alert("fdsgdfg");
            }
            if (step.second) {
                alert("dfgdfg");
            }

        }
    });
});

Alternatively:

$.ajax({
    type: "POST",
    url: "some.php",
    data: "name=John&location=Boston",
    success: function(msg){
        alert( "Data Saved: " + msg );
    }
});

As stated in the jQuery documentation, you pass data with the request using the data option:

jQuery(document).ready(function() {
    $.ajax("valid.php", {
        type: "POST",
        dataType: "json",
        data: { name: $('#name').val(), email: $('#email').val() }, 
        success: function(step) {

            if (step.first) {
                alert("fdsgdfg");
            }
            if (step.second) {
                alert("dfgdfg");
            }

        }
    });
});