Click here to Skip to main content
Click here to Skip to main content

Refresh Portion Of Your Web Page Using XMLHTTP

, 15 May 2001
Rate this:
Please Sign up or sign in to vote.
This article explains how portion of a web page can be selectively refreshed using XMLHTTP
<!-- Download Links --> <!-- Add the rest of your HTML here -->


Did you ever have to refresh only selective part of a web page without having to refresh the whole page?. If yes, you are not alone. Fortunately, there are number of solutions which can address this issue, including remote scripting and XMLHTTP. This articles explains how a part of web page can be refreshed by using XMLHTTP, without having to refresh the whole page .


XMLHTTP object can be used to make HTTP request from the web browser to the server. XMLHTTP is part of Microsoft's XML parser and it is already installed in your machine if you have Internet Explorer.

Please refer MSDN help on how to use XMLHTTP object. Also, I recommend you reading my article Making HTTP Communication from MFC/Windows Application first, because I use the same techniques here too.


Sample app screenshot

In the above example web page, we can select a country from the country list box. For a country selected, we'll display list of states/province for that country. When you click on a country, a HTTP request to the web server will be send to get all the states for the specific country. States list box will be refreshed with the result from the server. Note that we are not using the submit to send a HTTP request to the web server. Instead, we use XMLHTTP since we do not want the whole page refreshed. Also, note that both request and response are in XML string and we will have to use the XML DOM to read the node values.

If you selected Canada in the country list box, the XML request string which is send from the web browser to the web server will look like below:

<RequestStates Country='Canada'></RequestStates>

The server (i.e. states.asp in this case) will process this request and sends back XML response, which looks like as shown below:

	<State>British Columbia</State>

The client has to process this XML response and update the states list box. The DisplayStates() function in demo.html takes care of this functionality.

Related Articles

The article Refreshing only part of your Web Page is on the same topic. However, it uses remote scripting (not XMLHTTP) to refresh part of web page.

Installation Notes

Download the sources (states.asp and demo.html) to the root directory of your web server. Note that the sample application assumes that your web server runs on the same machine as the client. If your web server runs on different machine, you have to change the URL name in XMLHTTP's open() method (in demo.html) appropriately. This sample application will not work if the URL specified is wrong.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Dhandapani Ammasai(Dan in short) is a software delivery manager at a top tier IT company in India.

Comments and Discussions

GeneralPlease use MSXML2.XMLHTTP and MSXML2.DOMDocument PinmemberUmut Alev17-Dec-06 22:13 
GeneralRefresh PinmemberDavid Pfahl7-Dec-05 13:17 PinmemberSean Rock2-Jul-05 0:47 
GeneralServer to client transfer Pinmembersundarbunny8-Jun-05 23:35 
GeneralRe: Server to client transfer PinmemberHazem Salem1-Nov-06 11:41 
Generaljavascript! PinsussAnonymous27-Sep-04 16:55 
GeneralRe: javascript! PinmemberAlex Korchemniy18-Dec-04 8:35 
QuestionXMLHTTP question? PinsussVeddy7-Oct-03 10:53 
Generalsubmit + iframes vs. xmlhttp PinsussNidi Iacobsohn1-Jun-03 3:27 
GeneralRe: submit + iframes vs. xmlhttp Pinmemberrobpinion21-Jul-03 20:39 
GeneralRe: submit + iframes vs. xmlhttp PinsussAnonymous13-Oct-05 2:36 
Generalxmlhttp Pinmemberarvindsha27-Nov-02 9:46 
Generalmissing value attribute Pinmember9key31-May-02 12:43 
GeneralGreat piece of code! PinmemberJulian Tysoe30-Jan-02 5:56 
Generalforeing Characters PinmemberHector2-Nov-01 11:50 
GeneralRe: foreing Characters PinmemberSandro Araújo16-Nov-01 8:27 
QuestionClient requirements? PinmemberTom Archer22-May-01 3:35 
AnswerRe: Client requirements? PinmemberGerald22-May-01 7:25 
GeneralRe: Client requirements? PinmemberTom Archer22-May-01 7:47 
GeneralRe: Client requirements? PinmemberGerald22-May-01 8:00 
GeneralRe: Client requirements? PinmemberJason Gerard23-May-01 9:42 
GeneralRe: Client requirements? PinmemberDhandapani Ammasai23-May-01 9:46 
GeneralRe: Client requirements? PinmemberWhiteTrailerTrash23-Nov-06 6:11 
GeneralRe: Client requirements? PinmemberGary Menzel25-Jul-01 14:40 
GeneralRe: Client requirements? PinmemberMark Bruk5-Sep-01 16:46 
GeneralRe: Client requirements? PinmemberAnonymous30-Aug-01 8:34 
GeneralRe: Client requirements? PinmemberMike McPhail21-Feb-03 8:04 
AnswerRe: Client requirements? PinmemberDhandapani Ammasai22-May-01 7:42 
AnswerCROSS BROWSER SOLUTION HERE PinmemberNathan Ridley16-Sep-02 3:30 
Generaltest PinmemberAnonymous16-May-01 23:22 
GeneralRe: test PinsussAnonymous6-Nov-02 7:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150326.1 | Last Updated 16 May 2001
Article Copyright 2001 by Dhandapani Ammasai
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid