Search code examples
javascriptjqueryjqueryform

Jquery form plugin not showing success function


I have this code:

$(".myform").live('submit', function(e){   
    var options = { 
        target: '.ajaxMessage',
        // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,
        success: function(data) {   
            alert(data);
            //$('#dialog-confirm').dialog('close');
            //$(".ajaxMessage").html(data).show().delay('5000').fadeOut("5000");
        },
        type: 'POST'

$(".myform").ajaxForm(options);

The firefox console is showing this as response

Response

1{"code":"OK"}

My data gets inserted in database correctly but i am not able to call that success function also in Firefox console i get the desired response with success message template,


Solution

  • Try and share some more of your code or use JsFiddle for code sharing, anywayz on my assumption i am sharing the code, hope it works for ya:

    $(".myform").on('submit', function(e){   
        var options = { 
            target: '.ajaxMessage',
            // target element(s) to be updated with server response 
            beforeSubmit:  showRequest,
            success: function(data) {   
                alert(data);
                //$('#dialog-confirm').dialog('close');
                //$(".ajaxMessage").html(data).show().delay('5000').fadeOut("5000");
            },
            error: function(){
            alert('Error!!!')
            },
            type: 'POST'
        }
    });