I have an HTML form in a PHP file like the attached snippet:
When I hit the "Save Details" button, I want the page to load a jQuery UI modal dialog. That dialog will execute a controller action (ex:savedetails) through Ajax. Essentially, the controller action will get all the POST details in "frmEmployees" and saves the changes to a database through Ajax.
I am interested in the logic to load the dialog with the Ajax content in it (Get all the POST variables through the controller action, say "/public/empdetailcontroller" via Ajax). So, far I have something like the HTML below.
Any Ideas?
Snippet:
<form name="frmEmployees" id="frmEmployees" method="POST" action="">
<table>
<tr><td>Name:</td><td><input type="text" name="empName" size="50"></td></tr>
<tr><td>City:</td><td><input type="text" name="empCity" size="50"></td></tr>
<tr><td>Country:</td><td><input type="text" name="empCountry" size="50"></td></tr>
<tr><td colspan=2 align=center><input type="button" name="btnsubmit" value="Save Details"></td></tr>
</table>
</form>
<div id="dialogSaveChanges"
title="Saving.."
style="display:none;"><p><span
class="ui-icon
ui-icon-info"
style="float:left; margin:0 7px 20px 0;"
></span><span id="dialogText-savechanges"></span></p></div>
<script language="JavaScript>
$(document).ready(function() {
$('#dialogSaveChanges').dialog({
autoOpen: false,
width: 400,
modal: true,
title: titleText,
closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
resizable: false,
buttons: {
Ok: function() {
$(this).dialog('close');
}
}
});
$('#btnSaveChanges').click(function() {
$('#dialogSaveChanges').dialog('open');
$("span#dialogText-savechanges").html("Your Changes have been saved successfully.");
});
});
</script>