|
|
|
ช่วยแก้โค๊ด realtime ajax php ตัวนี้หน่อยครับ [Ajax Realtime] ให้เวลาเอาเมาล์วางที่ข้อความเเล้วมันหยุดรีเฟสอ่ะครับ มือใหม่ |
|
|
|
|
|
|
|
ช่วยแก้โค๊ด realtime ajax php ตัวนี้หน่อยครับ
https://www.thaicreate.com/tutorial/ajax-realtime.html
ให้เวลาเอาเมาล์วางที่ข้อความเเล้วมันหยุดรีเฟสอ่ะครับ มือใหม่
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Ajax Tutorial</title>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Sort) {
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 = 'qill2.php';
var pmeters = 'mySort='+Sort;
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();">
<h1>My Customer</h1>
<script language="JavaScript">
var refresh = '';
function bodyOnload()
{
doCallAjax('CustomerID')
refresh = setTimeout("doLoop();",500);
}
function doLoop()
{
bodyOnload();
}
function stopRefresh()
{
clearTimeout(refresh);
}
</script>
<script language="javascript">
function js_popup(theURL,width,height) { //v2.0
leftpos = (screen.availWidth - width) / 2;
toppos = (screen.availHeight - height) / 2;
window.open(theURL, "viewdetails","width=" + width + ",height=" + height + ",left=" + leftpos + ",top=" + toppos);
}
</script>
<span id="mySpan" onmouseover="stopRefresh()" onmouseout="doLoop()"></span>
</body>
</html>
Code (PHP)
[php]<?
echo '<a >เอาเมาล์วางที่ข้อความนี้แล้วหยุดรีเฟส</a>';
?>
[/php]
Tag : PHP, MySQL, HTML/CSS, JavaScript, CakePHP, Tablets
|
|
|
|
|
|
Date :
2013-12-28 16:18:18 |
By :
jo |
View :
759 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[glow=red]แก้ ๆๆๆ ๆๆ[/glow]
หน้าแรก
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Ajax Tutorial</title>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Sort) {
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 = 'qill2.php';
var pmeters = 'mySort='+Sort;
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();">
<h1>My Customer</h1>
<script language="JavaScript">
var refresh = '';
function bodyOnload()
{
doCallAjax('CustomerID')
refresh = setTimeout("doLoop();",500);
}
function doLoop()
{
bodyOnload();
}
function stopRefresh()
{
clearTimeout(refresh);
}
</script>
<script language="javascript">
function js_popup(theURL,width,height) { //v2.0
leftpos = (screen.availWidth - width) / 2;
toppos = (screen.availHeight - height) / 2;
window.open(theURL, "viewdetails","width=" + width + ",height=" + height + ",left=" + leftpos + ",top=" + toppos);
}
</script>
<span id="mySpan" onmouseover="stopRefresh()" onmouseout="doLoop()"></span>
</body>
</html>
หน้า 2
Code (PHP)
<?
echo '<a >เอาเมาล์วางที่ข้อความนี้แล้วหยุดรีเฟส</a>';
?>
|
|
|
|
|
Date :
2013-12-28 16:20:00 |
By :
jo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำยังไงครับใครรู้ช่วยบอกหน่อย
|
|
|
|
|
Date :
2013-12-28 16:33:12 |
By :
jo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|