Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery form plugin success callback is not executing


I am not sure why the jQuery form plugin success callback function is not executing. Why is the callback not executing and how do I execute the callback?

code:

 <script type="text/javascript">
    $(document).ready(function() {

      var insertOptions =
        { 
            // other available options: 
            url:       'manage_livestock/insert_livestock',
            type:      'post',
            dataType:  'json', 
            clearForm: true,
            //resetForm: true 

            // $.ajax options can be used here too, for example: 
            timeout:   3000,

            success: showResponse
        };

        $("#livestock").ajaxForm(insertOptions);
    });  

    function showResponse(responseText, statusText, xhr, $form)
    {
        alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
            '\n\nSuccess!'); 
    }
</script>

-Rich

like image 704
dottedquad Avatar asked May 24 '11 05:05

dottedquad


1 Answers

As I proposed in the comments - the response should be a valid json, otherwise you could change the type to html.

like image 180
zerkms Avatar answered Oct 26 '22 04:10

zerkms