Reload Spring MVC response page in jQuery Dialog

Go To StackoverFlow.com

0

i am trying to submit a form with jQuery to a Spring MVC Controller Method and load the response page in a div tag of a dialog.

jquery in dialog

$("#findbtn").click(function() {
    $("#content").load($("#searchform").submit());
});

Form

 <form id="searchform" method="POST" action="/select">
                <input type="text" id="csearch" name="csearch" /><input
                    type="button" id="findbtn" />
    </form>

Controllermethod

@RequestMapping(value = "select", method = RequestMethod.POST)
public String getSelection(Model model, @RequestParam("csearch") String find) {

    model.addAttribute("list", list);
    return "/select";
}

The Problem is that the response page is shown as a new page and not in the dialog. Is there a way to load it in the dialog.

Note: The response page (/select), happens to be the same page as the current loaded page in the dialog. That means i want to reload the content of the dialog with the same page, except the list is different.

thanks

2012-04-05 20:07
by KenavR
What dialog are you using? Jquery UI Dialog - MarkOfHall 2012-04-06 02:24


2

You are not using JQuery load correctly (and its not the right method for what you want to do). $.load() takes a URL, you are providing a dom element.

There are lots of examples of "jquery ajax form submit" on the web.

$.ajax({type:'POST', url: '/select', data:$('#searchform').serialize(), success: function(response) {
    $('#content').html(response);
}});
2012-04-05 22:57
by nickdos
Ads