index.php
<html >
<head>
<script src="js/jquery.js"></script>
<script language="javascript">
$(document).ready(function()
{
$("#frm").submit(function()
{
if($('#field1').val() && $('#field2').val())
{
$.post("index_reg.php",{ field1:$('#field1').val(),field2:$('#field2').val() } ,function(data){
if(data=='success')
{
$(document).ready(function(){
alert('ذخیره شد');
});
}
else
{
$(document).ready(function(){
alert( 'ذخیره نشد!!! ');
});
}
});
return false; //not to post the form physically
}
});
});
</script>
<"form name="frm" id="frm" method="post" action="index_reg.php">
<input type="text" name="field1" id="field1" value="">
<input type="text" name="field2" id="field2" value="">
<button class="btn btn-inverse login-btn" type="submit">ذخیره</button>
</form>
</body>
</html>