|
 |
|
ทำยังไงให้ Ajax หยุด Loop เมื่อมีการใส่ข้อมูลลงใน Text Box |
|
 |
|
|
 |
 |
|
<?php
session_start();
if (!isset($_SESSION['superviser'])) {
echo "<center>";
echo "<font color=red><center><b>คุณยังไม่ได้ล็อคอินเข้าสู่ระบบ</b></center></font><br>";
echo "กรุณารอสักครู่ หรือ ";
echo "<a href=form_login.php target_parent>คลิกที่นี่</a><p>";
echo "<img src='images/loading.gif' height='30' width='30'>";
echo "</center>";
echo "<meta http-equiv='refresh' content='3;url=form_login.php'>";
exit();
}
?>
<html>
<head>
<title>.: Superviser Page :.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
background-color: #C2EFDD;
}
</style>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Search) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'supervi_search.php';
var pmeters = 'mySearch='+Search;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
</script>
<body Onload="bodyOnload();">
<form name="frmMain" action="" method="POST">
<script language="JavaScript">
function bodyOnload()
{
doCallAjax('')
setTimeout("doLoop();",2000);
}
function doLoop()
{
bodyOnload();
}
</script>
<p> </p>
<table width="800" border="0" align="center">
<tr>
<td>
<p><strong>รหัสรายงาน</strong>:
<input type="text" name="txtSearch" id="txtSearch">
<input type="button" name="btnSearch" id="btnSearch" value="ค้นหา" OnClick= "JavaScript:doCallAjax(document.getElementById('txtSearch').value,'1');">
</p>
</td>
</tr>
</table>
</form>
<p><span id="mySpan"></span></p>
<table width="219" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<th width="207" scope="col"><p><a href="supervi_pwd.php">เปลี่ยนรหัสผ่าน</a> </p>
<p><a href=javascript:if(confirm('ยืนยันการออกจากระบบ')==true){window.location='logout.php';}>ออกจากระบบ</a></p></th>
</tr>
</table>
</body>
</html>
*เมื่อมีการใส่ข้อความลงใน text box เพื่อค้นหาข้อมูลแล้ว อยากให้ หยุด Loop ชั่วคราว เพื่อโชว์ข้อมูลที่ค้นหา มิเช่นนั้น Loop มันจะ โหลดหน้าจอใหม่ ทำให้ข้อมูลที่ค้นหา แสดงแค่แป็ปเดียว
Tag : PHP, MySQL, Ajax

|
|
 |
 |
 |
 |
Date :
2011-08-22 09:06:34 |
By :
Necrotorture |
View :
1209 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
return false;
|
 |
 |
 |
 |
Date :
2011-08-22 09:36:20 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หง่า . .. สั้น ๆ แต่ไม่ได้ใจความ งง คับพี่น้อง 
|
 |
 |
 |
 |
Date :
2011-08-22 09:39:53 |
By :
Necrotorture |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยด้วยค๊าบบ
|
 |
 |
 |
 |
Date :
2011-08-22 15:03:36 |
By :
Necrotorture |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|