AJAX Example code showing XML response in a DIV tag

This is an example code which demonstrates how we can show the response from a XML file to the DIV tag.

<html>
<head>
<title>Using responseText with innerHTML</title>
 
<script type="text/javascript">
var xmlHttp;
 
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
 
function startRequest() {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", "response.xml", true);
    xmlHttp.send(null);
}
 
function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            document.getElementById("results").innerHTML = xmlHttp.responseText;
        }
    }
}
</script>
</head>
 
<body>
    <form action="#">
        <input type="button" value="Search"
                onclick="startRequest();"/>
    </form>
    <div id="results"></div>
</body>
</html>


Notice the line in Javascript.

document.getElementById("results").innerHTML = xmlHttp.responseText;

This is doing all the magic for you.

Below are the contents of reponse.xml

<table border="1">
    <tbody>
        <tr>
            <th>My Name</th>
            <th>Location</th>
            <th>Age</th>
        </tr>
        <tr>
            <td>John</td>
            <td>NH</td>
            <td>20</td>
        </tr>
        <tr>
            <td>Peter</td>
            <td>CA</td>
            <td>25</td>
        </tr>
        <tr>
            <td>Hary</td>
            <td>NC</td>
            <td>33</td>
        </tr>
    </tbody>
</table>


Keep both the files in the same directory on server and run it.

46 Post Comment

Anonymous said...

This is helpful. Thx

ch2online said...

Cool blog you got here. It would be great to read more concerning this matter.

Anonymous said...

nike free, kate spade outlet, prada handbags, coach factory outlet, oakley sunglasses, true religion, coach purses, oakley sunglasses, louboutin, michael kors outlet, ray ban, louis vuitton outlet online, jordan shoes, coach factory, longchamp outlet, ray ban sunglasses, louis vuitton handbags, coach outlet, nike shoes, true religion outlet, tiffany and co, michael kors outlet, true religion jeans, oakley sunglasses, gucci outlet, louboutin, chanel handbags, polo ralph lauren outlet, oakley sunglasses, ray ban sunglasses, toms shoes, oakley sunglasses, tory burch outlet, air max, coach outlet store, nike air max, polo ralph lauren, burberry outlet online, burberry outlet online

Anonymous said...

air max, nfl jerseys, nike free, marc jacobs, chi flat iron, air max, hogan, air jordan, nike free, mcm handbags, new balance shoes, ghd, mont blanc, louis vuitton, yoga pants, louis vuitton, bottega, karen millen, longchamp, juicy couture outlet, louboutin, abercrombie and fitch, rolex watches, nike air max, ralph lauren, reebok outlet, birkin bag, ralph lauren, nike air max, vans, lancel, north face outlet, insanity, supra shoes, lululemon, ferragamo shoes, beats by dre, timberland, hollister, converse shoes, mulberry

pai young said...

Salomon Speedcross Online Shop Artikel Shizu Cloud leeren Hülsen Road, fast auf der Linie, ein Eintrag Ihrer eigenen Wind sein, um zu töten abzuwerfen Straße. Shizu nicht mehr wirkt, und sind intelligente Menschen, wir haben etwas zu sagen haben. Faint Worten, ihre leeren Worte, während Salomon Speedcross Salomon Schuhe Günstig Online Shop Cheapang Yun hat den Lärm Schild gelehnt.

Salomon Speedcross Salomon Outlet Online Shop Generation der Fee. Cheapang Yun Pente leere Worte, um es mehr schämen Begriff Wind. Dann mögen Sie diese in Verbindung mit den Bären, wenn Billig. Einundzwanzig Leute schätzen literarisches um aufzuholen mit Ihnen, Sie haben, um es in die Salomon Speedcross Online Shop sechsundzwanzig Hunde gehen zu leben. Noch mehr als mit anderen, erst siebzehn Jahre alt in der Lage, auf die Sie stampfen, wie Sie nicht essen Scheiße. Sie diese Abfälle.

Salomon Speedcross Salomon Schuhe Outlet Online Shop Gas bösen alten Dame. Artikel Wolke leer Stimm Mahlzeit Schimpfwort Gesicht gnadenlos, gelegentlich schlagen die Lehren auch eigenes Kind zu ihr bringen, es war wirklich in dem Stand, und zog den Schlüssel .

pai young said...

Je sais. dit un pas cher, le doudoune moncler femme pas cher coeur si pas cher faible éclaté de joie. La jeune fille était si belle à voir, il soupçonne toujours pas cher doudoune moncler femme pas cher doudoune moncler femme pas cher sentir drôle beauté est amusant, surtout une fille simple si pas cher, il est intéressant. Allez au diable. J'ai quelque chose à vous dire. sourire Puchi pas cher, pas de tension, et de parler doudoune moncler femme pas cher agile beaucoup. Vous amener les gens moncler pas cher à ma fille à la maison passé. Quel est le rapport avec elle, et mon cœur aigre une nuit, ressembler à deux pas cher n'ont tout simplement pas d'importance. Vous ne vous souciez pas où elle est à la hausse. demandé à un pas doudoune moncler femme pas cher cher délibérée. Mon entreprise. Amour d'aller où aller. pas cher ne veut pas dire le jour de la Doudoune Moncler solde porte avec des choses bon marché, qu'elle ne pouvait pas comprendre, mais prétendent heureusement doudoune moncler femme pas cher indifférence regard, donc pas cher n'est plus demandé d'aller.

Meiqing Xu said...

15910meiqing
instyler curling iron
abercrombie fitch,abercrombie and kent,abercrombie & fitch,abercrombie outlet,abercrombie kids
toms outlet
ralph lauren uk
air jordan 11
ghd straighteners
louis vuitton handbags
michael kors uk
oakley outlet
nike huarache
air force 1
celine outlet
ray ban glasses
uggs on sale
nike roshe run
ray ban sunglass
louis vuitton
louis vuitton handbags
mont blanc pens
michael kors outlet
adidas superstar
coach outlet
louis vuitton
oakley sunglasses cheap
ray ban glasses
oakley sunglasses
air jordans
louis vuitton handbags
jeremy scott shoes
louis vuitton handbags

ninest123 Ninest said...

ninest123 11.24
louboutin uk, nike outlet, louis vuitton handbags, michael kors outlet online, nike air max, ralph lauren polo, longchamp bags, replica watches, christian louboutin, uggs outlet, burberry factory outlet, tiffany jewelry, uggs on sale, louis vuitton outlet, michael kors handbags, burberry outlet, tory burch outlet, ray ban sunglasses, oakley sunglasses, louis vuitton outlet, longchamp outlet, oakley sunglasses, ray ban sunglasses, ray ban sunglasses, oakley sunglasses, gucci handbags, oakley sunglasses, cheap jordans, ralph lauren outlet, tiffany jewelry, louis vuitton, uggs outlet, replica watches, michael kors outlet, prada handbags, michael kors, prada outlet, uggs on sale, christian louboutin, nike air max, louis vuitton outlet online, louboutin shoes, uggs on sale, nike free, michael kors outlet online, michael kors outlet store, longchamp outlet, cheap oakley sunglasses

ninest123 Ninest said...

north face pas cher, ray ban uk, polo lacoste pas cher, nike air max, nike air max uk, vanessa bruno pas cher, nike roshe uk, nike roshe run pas cher, abercrombie and fitch UK, nike air force, michael kors, michael kors outlet online, polo ralph lauren uk, true religion outlet, lululemon outlet, new balance, timberland pas cher, louboutin pas cher, michael kors uk, nike tn pas cher, hogan sito ufficiale, hermes pas cher, nike blazer pas cher, nike free pas cher, vans pas cher, nike air max pas cher, ralph lauren pas cher, nike air max uk, abercrombie and fitch, lunette oakley pas cher, true religion outlet, true religion jeans, coach outlet, burberry pas cher, sac guess pas cher, converse, north face uk, nike trainers uk, nike free, true religion outlet, hollister uk, mulberry uk, coach outlet store online, coach purses, michael kors, lunette ray ban pas cher, longchamp pas cher, longchamp soldes, jordan pas cher

ninest123 Ninest said...

supra shoes, coach outlet, bottes ugg pas cher, moncler, converse shoes outlet, canada goose pas cher, canada goose uk, juicy couture outlet, juicy couture outlet, moncler pas cher, sac louis vuitton, links of london uk, swarovski jewelry, sac louis vuitton, ugg,uggs,uggs canada, toms shoes, canada goose jackets, karen millen uk, montre pas cher, lancel, canada goose, moncler, uggs outlet, michael kors outlet, moncler uk, ugg uk, barbour, thomas sabo uk, wedding dresses uk, ugg,ugg australia,ugg italia, canada goose outlet, doke & gabbana, barbour jackets uk, replica watches, ugg pas cher, louis vuitton uk, moncler outlet, pandora charms, swarovski uk, marc jacobs, louis vuitton, canada goose outlet, pandora jewelry, louis vuitton, canada goose jackets, moncler, pandora uk, moncler jackets, moncler, hollister, pandora jewelry, canada goose

ninest123 Ninest said...

abercrombie and fitch, nike roshe run, soccer shoes, oakley, wedding dresses, polo ralph lauren, nike air max, nike air max, vans scarpe, valentino shoes, vans outlet, herve leger, p90x workout, beats by dre, iphone 5s cases, soccer jerseys, hollister, ray ban, instyler ionic styler, iphone cases, bottega veneta, insanity workout, s6 cases, timberland boots, giuseppe zanotti, jimmy choo outlet, iphone 6s plus cases, iphone 6 cases, mcm handbags, converse, reebok outlet, babyliss pro, louboutin, lululemon outlet, chi flat iron, mont blanc, new balance shoes, iphone 6 plus cases, north face outlet, salvatore ferragamo, mac cosmetics, asics running shoes, ghd hair, north face outlet, hollister clothing, softball bats, nfl jerseys, hermes handbags, ipad cases, celine handbags, gucci, iphone 6s cases
ninest123 11.24

Cran Jane said...

Coach Outlet North Face Jackets Oakley Sunglasses Toms Outlet North Face Outlet Nike Outlet Nike Hoodies Tory Burch Flats Marc Jacobs Handbags Jimmy Choo Shoes Jimmy Choos
Burberry Belt Tory Burch Boots Louis Vuitton Belt Ferragamo Belt Marc Jacobs Handbags Lululemon Outlet Christian Louboutin Shoes True Religion Outlet Tommy Hilfiger Outlet
Michael Kors Outlet Coach Outlet Red Bottoms Kevin Durant Shoes New Balance Outlet Adidas Outlet Coach Outlet Online Stephen Curry Jersey

Eric Yao said...

Skechers Go Walk Adidas Yeezy Boost Adidas Yeezy Adidas NMD Coach Outlet North Face Outlet Ralph Lauren Outlet Puma SneakersPolo Outlet
Under Armour Outlet Under Armour Hoodies Herve Leger MCM Belt Nike Air Max Louboutin Heels Jordan Retro 11 Converse Outlet Nike Roshe Run UGGS Outlet North Face Outlet
Adidas Originals Ray Ban Lebron James Shoes Sac Longchamp Air Max Pas Cher Chaussures Louboutin Keds Shoes Asics Shoes Coach Outlet Salomon Shoes True Religion Outlet
New Balance Outlet Skechers Outlet Nike Outlet Adidas Outlet Red Bottom Shoes New Jordans Air Max 90 Coach Factory Outlet North Face Jackets North Face Outlet

On Line said...



فوائد الخل في التنظيف :- ازالة الترسبات من الأواني كإبريق الشاي أو غلاية القهوة أو غيرهما؛ يملأ الوعاء المراد تنظيفه حتى النصف تماماً بالماء والباقي من الخل، ثم يوضع على النار حتى يصل إلى درجة الغليان ويترك ليغلي عدة دقائق، ثم يرفع عن النار ويسكب ما فيه، ويغسل بالماء البارد فقط عدة مرات. التلميع: هي عملية إضفاء البريق واللمعان على الأسطح كالمرايا والزجاج والفضيات؛ وذلك بمسحها بقطعة قطنية مبللة بالخل الأبيض ثم تجفيف الأسطح بقطعة قطنية أخرى. تنظيف المايكرويف مع الخل الأبيض: أصبحت عملية تنظيف المايكرويف وإزالة البقع المتراكمة عليه من الطعام بسبب عمليات التسخين المتكررة أمراً في غاية السهولة، وذلك بوضع طبق فيه فنجان قهوة من الماء ومثله من الخل الأبيض ووضعه داخل المايكرويف حتى يغلي المزيج، يطفأ المايكرويف ويترك دون فتحه مدة ساعتين، بعدها يفتح ويزال الطبق، وبواسطة قطعة قطنية يمسح من الداخل والنتيجة سوف تبهرك. , شركة تنظيف شقق بجدة , شركة تنظيف شقق بالاحساء , شركة تنظيف شقق بالدمام , شركة تنظيف شقق بالقطيف , شركة تنظيف منازل بالاحساء , شركة تنظيف منازل بحائل الحفاظ علي المنزل > شركة تسليك مجارى بجدة
شركة كشف تسربات المياه بالرياض



عرفان صادقي said...

بک لینک

بانک مقاله

دانلود آهنگ

تبادل لینک

ساخت وبلاگ

ابزاردهی

Malaysia Escorts said...

Pakistani Escorts Abey

Malaysia Escorts said...

Pakistani Escorts

Sky Host Pakistan said...

Leading web hosting comopany in Pakistan - Sky Host Pk

Malaysia Escorts said...

Vip Lahore Girls

Malaysia Escorts said...

Vip Karachi Girls

Malaysia Escorts said...

Vip Lahore Escorts

Hoài Nguyễn said...

Thị trường bất động sản đầu năm 2017 với sự xuất hiện của dự án eco dream nguyễn xiển. Chung cư eco dream là dự án căn hộ cao cấp với mức giá hợp lý, chung cu eco dream là cơ hội đầu tư sinh lời cho nhà đầu tư. Ngoài ra, chung cư Housinco grand tower cũng là dự án nổi bật với hơn 200 căn hộ đạt chuẩn 5 sao. Chung cư Vinhomes gallery là siêu dự án trung tâm quận Ba Đình, chung cư Vinata Towers là dự án đầu tiên được đầu tư bởi Nhật Bản. Chung cư eco green city chỉ còn hơn 100 căn hộ cuối cùng. Chung cư The legend sở hữu vị trí trung tâm quận Thanh xuân. Chung cư Tháp doanh nhân vị trí đắc địa quận Hà đông.

Malaysia Escorts said...

Vip Karachi Escorts

Malaysia Escorts said...

Escorts Girls in Lahore

Malaysia Escorts said...

Lahore Escorts Girls

Malaysia Escorts said...

Karachi Escorts Girls

Unknown said...

michael kors handbags
oakley sunglasses
ralph lauren outlet
yeezy boost 350
nike blazer pas cher
cheap jordan
michael kors handbags
san francisco 49ers jerseys
polo ralph lauren
packers jerseys

Malaysia Escorts said...

http://www.dubaiescorts.xyz/

Malaysia Escorts said...

Vip Dubai Escorts Net

Malaysia Escorts said...

Dubai Life UAE

Malaysia Escorts said...

Vip Dubai Life

chenmeinv0 said...

cheap oakley sunglasses
oakley sunglasses
christian louboutin heels
oakley sunglasses outlet
coach outlet online
oakley vault
nike air max uk
oakley sunglasses cheap
nike air max
valentino heels
hzx20170418

Malaysia Escorts said...

Dubai Life

Malaysia Escorts said...

Vip Dubai Life

Malaysia Escorts said...

Vip Dubai Girls Life

sana said...

http://www.dubaiescorts.xyz

fb login said...

Thanks for your post. It is very useful. I would like to share the article on my site to read as needed.

شركة قمة الدقة للخدمات المنزلية said...

شركة تنظيف منازل بالرياض
شركة كشف تسربات المياه ببقيق

ninest123 said...

nike outlet
fitflop sandals
michael kors outlet online
nike air max
air max 95
fitflops
coach outlet
cheap oakley sunglasses
rolex replica
ralph lauren sale clearance
mt0713

صور said...

صور
https://profounddetectivetiger.tumblr.com

sana kiran said...

Dubai Escorts

Quang Đào Duy said...

Chung cư Green Pearl nằm trong quần thể Dự án Green Pearl tại số 378 Minh Khai, Vĩnh Tuy, Hai Bà Trưng, Hà Nội là một vị trí đắc địa thuộc cửa ngõ phía Nam của Thủ đô, tiếp giáp với đường Minh và KĐT times city. Căn hộ chung cư cao cấp Green Pearl sẽ mở ra không gian sống xanh, trong lành, KHÔNG ồn ào, KHÔNG khói bụi ngay trong lòng đô thị.
Chung cư Green Pearl

Dubai Escorts said...

Dubai Escorts Me


Dubai Escorts


Dubai Escort


VIP Dubai Escorts


Dubai Escorts Girls


Dubai


Escorts Dubai


Indian Escorts in Dubai


Pakistani Escorts in Dubai


Escorts


Escort


Escorts in Dubai


South Escorts in Dubai


UAE Escort Girls


Dubai Escorts Call Girls


Call Girls in Dubai


Model in Dubai


Dubai Escort VIP


Dubai Girls


UAE Girls

sana kiran said...

Dubai Escorts Me


Dubai Escorts


Dubai Escort


VIP Dubai Escorts


Dubai Escorts Girls


Dubai


Escorts Dubai


Indian Escorts in Dubai


Pakistani Escorts in Dubai


Escorts


Escort


Escorts in Dubai


South Escorts in Dubai


UAE Escort Girls


Dubai Escorts Call Girls


Call Girls in Dubai


Model in Dubai


Dubai Escort VIP


Dubai Girls


UAE Girls

Dubai Escorts

Dubai Escorts

Malaysia Escorts

Dubai Escorts

Dubai Escorts

ben daigege said...

nike foamposite
coach factory outlet
true religion jeans
mulberry handbags
futbol baratas
nike store uk
kevin durant shoes
michael kors outlet
true religion jeans
nfl jersey wholesale
chanyuan2017.09.30

crazzle plus said...

Lucky Patcher Download

Post a Comment

Search Web......