Suppose you have the following markup
<div id="__DialogPanel" style="display:none" title=""></div>
With this code, you set up a dialog
$("#__DialogPanel").dialog({ autoOpen: false, resizable: false, position: 'center', stack: true, height: 'auto', width: 'auto', modal: true });
With this code, you show the dialog and include the results of the ajax call
$.ajax({ type: "get", dataType: "html", url: 'some/url', data: {}, success: function(response) { $("#__DialogPanel").empty().html(response).dialog('open'); } });
With this code, you submit the form in a dialog box and then close it if everything is OK or the form is displayed again if there are errors
$.ajax({ type: 'post', dataType: 'html', url: '/someother/url', async: false, data: $("#myform").serialize(), success: function (response, status, xml) { //Check for error here if (error) { $("#myform").parent().html('').html(response); } else { $("#__DialogPanel").dialog('close'); } } });
Hope this helps!
source share