ajax callback function
ajax callback function
why function aSuccess don't work
- <?php
if($_REQUEST['iusername'] != ''){
echo 'เริ่มต้นเวลา '.date('h:i:s')."\n";
exit();
}else{
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ส่งข้อมุลแบบ post ด้วย jQuery</title>
<script src="plus/jQuery/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
/*<!---=-=-=-=-=-=-=-[ jquery api ajax ]-=-=-=-=-=-=-=--->*/
function aComplete(){ alert('com')
/* ทำงานทั้งสำเร็จ และมี error */
$('#blockPreload').removeClass('preload').addClass('preloadHide');
}
function aPreload(){
$('#blockPreload').removeClass('preloadHide').addClass('preload');
}
function aSuccess(){
alert('succ');
}
function aShowError(XMLHttpRequest, textStatus, errorThrown){
alert('jQuery ajax\nstatus = '+textStatus+'\nerror = '+errorThrown+'\nresponse =\n'+XMLHttpRequest.responseText);
}
$.ajaxSetup({
beforeSend:aPreload
,cache:false
,complete:aComplete
,error:aShowError
,success:aSuccess
,type:'POST'
});
$(function(){
$('#testF').submit(function(){
data=$('#testF').serialize()
$.post('jQueryAjax.php' ,data ,function(response){
//alert(response);
});
return false;
});
})
</script>
<link href="plus/plus.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="testF" method="post">
<label for="iusername">รหัสผู้ใช้</label>
<input type="text" name="iusername">
<br>
<label for="ipassword">รหัสผ่าน</label>
<input type="password" name="ipassword">
<input type="submit" name="isubmit" value="ส่งข้อมูล">
</form>
<div id="blockPreload" class="preloadHide"><img src="plus/images/preload.gif" width="128" height="15" alt="preload"></div>
</body>
</html>
<?php
}
?>