Вы должны отправить ajax-запрос в файл, где вы используете свой класс PHP $employee->save()
<script type="text/javascript">
function ButtonSaveClick()
{
$.ajax({
url: '[.. to your php file ..]',
data: $('#employeeFrm').serialize(), //using serialize to POST every field (<input />)
dataType: 'json', //only if you wanna return with JSON
success: function(data) {
// callback when done posting
//when doing json
if(data.status)
{
alert(data.message);
// refreshList() or somthing
}
else
{
alert(data.message);
};
}
});
}
$(document).ready(function(){
// Demo modal
function openModal()
{
$.modal({
content: '<p>Please make sure that all the information is correct</p>'+
'<form id="employeeFrm">'+
'<ul class="simple-list with-icon">'+
' <li>First Name:</li>'+
' <li>Last Name:</li>'+
' <li>Address:</li>'+
' <li>City:</li>'+
' <li>State:</li>'+
' <li>Zip Code:</li>'+
' <li>Position:</li>'+
' <li>Social Security #:</li>'+
' <li>Drivers License:</li>'+
' <li>Drivers License State:</li>'+
'</ul>'+
'</form>',
title: 'Confirm Application',
maxWidth: 500,
buttons: {
'Confirm': function(win) { ButtonSaveClick(); },
'Cancel': function(win) { win.closeModal(); }
}
});
}
// Demo modal
openModal();
});
</script>
Так что, если мой php-файл я использую в моем сообщении ajax:
include_once "[dbfile]";
include_once "[employeeClass is stored]";
$employee = new Employee();
if($employee->build($_POST))
{
//when successfully build
//return json way
echo json_encode(array('status'=>true, 'message'=>'Successfull')); exit;
//return non json way
echo 'Successfull'; exit;
}
else
{
//when failed with building
//return json way
echo json_encode(array('status'=>false, 'message'=>'failed')); exit;
//return non json way
echo 'failed'; exit;
};