Jsp automatic page refresh

Source: Internet
Author: User


How to automatically refresh the page:
1. <% response. setHeader ("Refresh", "3"); %> // 3 seconds

2.

Add this codeOrRegion

20 indicates refreshing the page every 20 seconds.

3

Automatic page Jump: add this codeOrRegion

20 means jump to the http://www.baidu.com page every 20 seconds

4. Automatically refresh js edition on the page
<Script language = "JavaScript">
Function myrefresh ()
{
Window. location. reload ();
}
SetTimeout ('myrefresh () ', 1000); // refresh once per second
</Script>


In the above 4, the method page refresh will flash... It is not recommended because it does not feel good.

It is best to use Asynchronous refresh .....



// Refresh the page in one minute
Function res (param ){
$. Ajax ({
Url: 'lastAuctionItem.html ',
Data: {aItemId: param },
Success: function (data ){
If (data. data. id> 0 ){
If (data. data. lastBid> 0 ){
Var price = parseInt (data. data. lastBid) + parseInt (data. data. increment );
$ ("# Bids" pai.html ("");
} Else {
Var price2 = parseInt (data. data. initialPrice) + parseInt (data. data. increment)
$ ("# Bids" pai.html ("");
}
}
If (data. error = "error "){
Return false;
}
}
});

}
// Refresh the page in one minute. Baidu checks the setInterval usage method. Specifically, the setInterval method is executed when the page is loaded ..

In the following example, this method calls the res function every minute... Res does not jump to the page after the page is submitted asynchronously for partial refresh.
SetInterval ("res ('$ {auctionItem. id}');", 1000*60 );







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.