[Solved]-Jquery ajax form success callback not being called

3πŸ‘

βœ…

In case anyone had a similar problem, here’s the final javascript I ended up using:

function upload_results_dialog($data_elem){
    var $dialog_box = $("#ajax-dialog-box"),
    data = $data_elem.attr("data");
    $.ajax({
        url: "../upload/" + data+ "/",
        success: function(response){
            $dialog_box.html(response);
            $dialog_box.dialog("option",
                {
                    title: "Upload",
                    height: 260,
                    width: 450,
                    buttons: {
                        Cancel: function(){
                            $(this).dialog('close');
                        },
                        Upload: function(){
                            upload($(this));
                        }
                    }
                }
            );
            $dialog_box.dialog('open');
        }
    });
}
function upload($dialog_box){
    var $form = $dialog_box.find("form"),
      iframe = $dialog_box.find("iframe"),
      $html = $($iframe.contents()),
      $iframe_form = $html.find("form");
    $iframe_form.html($form.contents());

    //Set the onload function
    $iframe.attr("onload","check_file_uploaded_valid()");
    $iframe_form.submit();
}

3πŸ‘

Ok I just spent hours with this same problem going through the js file line by line. It was working one second and then the next it wasnt. My problem was – I had deleted the target div for the results. Once i put that back in, it worked fine.

πŸ‘€JD0000

2πŸ‘

Happened to me as well. Problem turned out to be the server wasn’t converting the entire object to proper JSON. Changed the return value to only the properties I needed:

return Json(new {Id = group.Id, Name = group.Name});
πŸ‘€Jeff Borden

0πŸ‘

You need to call $('#form-id').ajaxForm(); in the document ready jQuery event so the plugin registers all the event handlers.

πŸ‘€Luis Aguilar

Leave a comment