JQuery-AJAX: No further request after timeout and delay in form post

Posted by Nogga on Stack Overflow See other posts from Stack Overflow or by Nogga
Published on 2010-06-02T18:09:57Z Indexed on 2010/06/02 18:14 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

I got a form containing multiple checkboxes. This form shall be sent to the server to receive appropriate results from a server side script.

This is already working.

What I would achieve now:

1) Implementing a timeout: This is already working, but as soon as a timeout occurs, a new request is not working anymore.

2) Implementing a delay in requesting results: A delay shall be implemented so that not every checkbox is resulting in a POST request.

This is what I have right now:

function update_listing() {

    // remove postings from table
    $('.tbl tbody').children('tr').remove();

    // get the results through AJAX
    var request = $.ajax({
                    type: "POST",
                    url: "http://localhost/hr/index.php/listing/ajax_csv", 
                    data: $("#listing_form").serialize(),
                    timeout: 5000,
                    success: function(data) {
                                    $(".tbl tbody").append(data);
                                },
                    error: function(objAJAXRequest, strError) {
                                    $(".tbl tbody").append("<tr><td>failed " + strError + "</td></tr>");
                                }
                    });

    return true;

}

Results are for now passed as HTML table rows - I will transform them to CSV/JSON in the next step.

Thanks so much for your advice.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX