Xmlhttp php js code demo for refreshing remote data (Chinese supported)

Source: Internet
Author: User

Xmlhttp, no refreshing sound, no funnel mark, the best effect, but high requirements on the browser, fortunately, my application is only a subsidiary function, so users do not need to enable this control ...... Finally, we decided to adopt this solution.

I wrote a test program with the following code for your reference:
==Test2.php ==============================
<?
Session_start ();
Echo "the current time is:". date ("Y-m-d H: I: s", time ());
?>

===Eg4.php ============================
<Script language = "javascript">
Function re ()
{
Var http = new ActiveXObject ("Microsoft. XMLHTTP ");
Http. open ("GET", "test2.php", false );
Http. send ();
Var str = bytes2BSTR (http. responsebody );
T. innerHTML = str;
SetTimeout ("re ()", 2000 );
}
</Script>

<Script language = vbscript>
Function bytes2BSTR (vIn)
Dim I
StrReturn = ""
For I = 1 To LenB (vIn)
ThisCharCode = AscB (MidB (vIn, I, 1 ))
If ThisCharCode <& H80 Then
StrReturn = strReturn & Chr (ThisCharCode)
Else
NextCharCode = AscB (MidB (vIn, I 1, 1 ))
StrReturn = strReturn & Chr (CLng (ThisCharCode) * & H100 CInt (NextCharCode ))
I = I 1
End If
Next
Bytes2BSTR = strReturn
End Function
</Script>


<Body onload = "re ();">
<Span id = t> loading data </span>
</Body>

In this way, when you run eg4.php, the page will display the current time, refresh every 2 seconds, no progress bar, no small funnel flag

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.