|
|
|
Auto refresh เหลือแต่ทำ auto refresh ก็เสร็จสมบูรณ์แล้วอ่ะ ขอบคุณคะ T-T |
|
|
|
|
|
|
|
var HttPRequest = false;
function chat() {
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 = '../chatroom/Chat3.php';
var pmeters = "tName=" + encodeURI( document.getElementById("txtName").value) +
"&tMessage=" + encodeURI( document.getElementById("txtMessage").value );
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;
// focus
var el = document.getElementById('mydiv');
el.tabIndex = 32456;
el.focus();
ใครเก่งช่วยแก้โค้ดด้านล่างนี้ให้เข้ากับโค้ดเต็มๆด้านบนด้วยคะ แก้จุดเดียวเป็นวันแล้ว เหลือแต่ทำ auto refresh ก็เสร็จสมบูรณ์แล้วอ่ะ ขอบคุณคะ T-T
document.getElementById("chat").style.display = 'none';
setTimeout("Load()", 5000);
function Load() {
myAjax("chat_message.php?lastid="+lastid, Display, false);
}
Tag : - - - -
|
|
|
|
|
|
Date :
2009-11-08 16:44:26 |
By :
gawalins |
View :
1457 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองใช้ setTimeOut ในการเรียก Web Page แบบซ้ำ ๆ เพื่อน Refresh ครับ
|
|
|
|
|
Date :
2009-11-08 20:52:29 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ
|
|
|
|
|
Date :
2011-08-10 05:23:18 |
By :
Nat |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|