2
<script>
    function showValues() {
        var str = $("form").serialize();
        $("#results").html(str);
    }
    $(":checkbox").click(showValues);
    $("select").change(showValues);
    showValues();
</script>

<form action="this.php" method="get">
    <input type="checkbox" name="check" value="$productid" id="ch1"/>
    <label for="ch1">check1</label>
</form>

As a checkbox is checked, the serialized URL is displayed on my page. But, as per my understanding of the point of serializing something is to place it into a dynamic url. Can someone give me advice as to how I can send the serialized result to another file via AJAX?

2 Answers 2

2

You can include your form fields in an AJAX call by using the data option:

function sendValues() {
    var str = $("form").serialize();
    $.ajax({
        url: "/that.php",
        data: str
    });
}

You can learn more about AJAX calls in the $.ajax() docs.

0
1

This is the basic usage of serialization and form submition.

var data = $(form).serialize();
$.post('post.php', '&'+data);

Read more more about $.post at http://api.jquery.com/jQuery.post/#example-3

Also have a look at $.ajax if you need more control on how you can submit your form. http://api.jquery.com/jQuery.ajax/

Not the answer you're looking for? Browse other questions tagged or ask your own question.