View Single Post
Old 01-23-2012, 04:09 AM   PM User | #1
q1h
New Coder

 
Join Date: May 2011
Posts: 34
Thanks: 7
Thanked 0 Times in 0 Posts
q1h is an unknown quantity at this point
Simplify jQuery syntax for form submission

I'm using this code to submit a hidden form from a link:

Code:
    $("#request").submit(function () {
        $.ajax({
            type: "POST",
            cache: false,
            url: "forms/add.php",
            data: $(this).serialize(),
            success: function (data) {
                $('#result').html(data);
            }
        });
        return false;
    });
    
    $("#request-link").live("click", function () {
        $("#request").submit();
    });
Is there anyway to combine it into one command instead of having the seperate statements? Thanks ...
q1h is offline   Reply With Quote