Jump to content

Ajax example sends data to "ajax_test.asp"


Mel_3

Recommended Posts

At http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.aspOne Ajax Example references the file ajax_test.asp1 - Is there anyway to see that file so we can see the "other side" of what is going on?2 = Is there a PHP example of this?I'm sure the ASP & PHP are about the same but it would be helpful to see both.Thanks for any help.PS - for reference=== Here is the example...xmlhttp.open("POST","ajax_test.asp",true);xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlhttp.send("fname=Henry&lname=Ford");=== And here is the TryIt Source<html><head><script type="text/javascript">function loadXMLDoc(){if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } }xmlhttp.open("POST","demo_post2.asp",true);xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlhttp.send("fname=Henry&lname=Ford");}</script></head><body><h2>AJAX</h2><div id="myDiv"></div><button type="button" onclick="loadXMLDoc()">Request data</button> </body></html>

Link to comment
Share on other sites

The other file really isn't important. It would just be an ASP file that wrote the response using Response.Write or something similar. If you replaced ajax_test.asp with http://www.google.com, the response would be (see below). the response is what ever HTML or text is output by the script.

<!doctype html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Google</title><script>window.google={kEI:"WuukTLGxL4y0MubroMgN",kEXPI:"17259,24279,24540,24813,25981,26710,26781,26799",kCSI:{e:"17259,24279,24540,24813,25981,26710,26781,26799",ei:"WuukTLGxL4y0MubroMgN",expi:"17259,24279,24540,24813,25981,26710,26781,26799"},ml:function(){},kHL:"en",time:function(){return(new Date).getTime()},log:function(b,d,c){var a=new Image,e=google,g=e.lc,f=e.li;a.onerror=(a.onload=(a.onabort=function(){delete g[f]}));g[f]=a;c=c||"/gen_204?atyp=i&ct="+b+"&cad="+d+"&zx="+google.time();a.src=c;e.li=f+1},lc:[],li:0,Toolbelt:{}};window.google.sn="webhp";window.google.timers={load:{t:{start:(new Date).getTime()}}};try{window.google.pt=window.gtbExternal&&window.gtbExternal.pageT();}catch(u){}window.google.jsrt_kill=1;var _gjwl=location;function _gjuc(){var b=_gjwl.href.indexOf("#");if(b>=0){var a=_gjwl.href.substring(b+1);if(/(^|&)q=/.test(a)&&a.indexOf("#")==-1&&!/(^|&)cad=h($|&)/.test(a)){_gjwl.replace("/search?"+a.replace(/(^|&)fp=[^&]*/g,"")+"&cad=h");return 1}}return 0}function _gjp(){!(window._gjwl.hash&&window._gjuc())&&setTimeout(_gjp,500)};window._gjp && _gjp()</script><style id=gstyle>body{margin:0}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}em{font-weight:bold;font-style:normal}.lst{width:496px}.tiah{width:458px}input{font-family:inherit}a.gb1,a.gb2,a.gb3,a.gb4{color:#11c !important}#gog{background:#fff}#gbar,#guser{font-size:13px;padding-top:1px !important}#gbar{float:left;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbs,.gbm{background:#fff;left:0;position:absolute;text-align:left;visibility:hidden;z-index:1000}.gbm{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}.gb1{margin-right:.5em}.gb1,.gb3{zoom:1}.gb2{display:block;padding:.2em .5em}.gb2,.gb3{text-decoration:none;border-bottom:none}a.gb1,a.gb2,a.gb3,a.gb4{color:#00c !important}a.gb2:hover{background:#36c;color:#fff !important}body{background:#fff;color:black}input{-moz-box-sizing:content-box}a{color:#11c;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#4272db}a:visited{color:#551a8b}a.gb1,a.gb4{text-decoration:underline}a.gb3:hover{text-decoration:none}#ghead a.gb2:hover{color:#fff!important}.ds{display:-moz-inline-box}.ds{border-bottom:solid 1px #e7e7e7;border-right:solid 1px #e7e7e7;display:inline-block;margin:3px 0 4px;margin-left:4px}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px;}.lsbb{background:#eee;border:solid 1px;border-color:#ccc #999 #999 #ccc;height:30px;display:block}.lsb{background:url(/images/srpr/nav_logo14.png) bottom;font:15px arial,sans-serif;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;vertical-align:top}.lsb:active{background:#ccc}.lst:focus{outline:none}.ftl,#fll a{margin:0 12px}#addlang a{padding:0 3px}.gac_v div{display:none}.gac_v .gac_v2,.gac_bt{display:block!important}</style><style>#po-bar{margin-bottom:4px;padding-top:1px;white-space:nowrap;z-index:98}#po-bar a,#po-bar a:visited{color:#4273db}#po-bar .flt{cursor:pointer;padding-bottom:0;text-decoration:none}#po-status{float:left}#po-box{background:#fff;border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;left:0;margin-top:.1em;position:absolute;z-index:101}#po-box a{display:block;padding:.2em .31em;text-decoration:none}#po-box a:hover{background:#558be3;color:#fff!important;text-decoration: none!important}#po-sc-lm a{display:inline;white-space:nowrap;padding:0}.po-lm{color:#aaa}a.po-selected{color:#000!important;font-weight:bold}a.po-unselected{color:#4273db!important}.po-selected .mark{display:inline}.po-unselected .mark{visibility:hidden}.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gb2{padding:.2em .5em}</style><script>google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return false};window.rwt=function(a,f,g,k,l,h,c,m){try{if(a===window){a=window.event.srcElement;while(a){if(a.href)break;a=a.parentNode}}var b=encodeURIComponent||escape,d;d=a.getAttribute("href");if(c&&c.substring(0,6)!="&sig2=")c="&sig2="+c;var n=["/url?sa=t","","&cd=",b(l),google.j&&google.j.pf?"&sqi=2":"","&ved=",b(m),"&url=",b(d).replace(/\+/g,"%2B"),"&ei=","WuukTLGxL4y0MubroMgN",h?"&usg="+h:"",c].join("");a.href=n;a.onmousedown=""}catch(o){}return true};window.gbar={qs:function(){},tg:function(e){var o={id:'gbar'};for(i in e)o[i]=e[i];google.x(o,function(){gbar.tg(o)})}};</script></head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f.q.focus();if(document.images)new Image().src='/images/srpr/nav_logo14.png'" ><textarea id=csi style=display:none></textarea><iframe name=wgjf style=display:none></iframe><div id=ghead><div id=gog><div id=gbar><nobr><b class=gb1>Web</b> <a href="http://www.google.com/imghp?hl=en&tab=wi" onclick=gbar.qs(this) class=gb1>Images</a> <a href="http://video.google.com/?hl=en&tab=wv" onclick=gbar.qs(this) class=gb1>Videos</a> <a href="http://maps.google.com/maps?hl=en&tab=wl" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://news.google.com/nwshp?hl=en&tab=wn" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://www.google.com/prdhp?hl=en&tab=wf" onclick=gbar.qs(this) class=gb1>Shopping</a> <a href="http://mail.google.com/mail/?hl=en&tab=wm" class=gb1>Gmail</a> <a href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" aria-haspopup=true class=gb3><u>more</u> <small>▼</small></a><div class=gbm id=gbi><a href="http://books.google.com/bkshp?hl=en&tab=wp" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://www.google.com/finance?hl=en&tab=we" onclick=gbar.qs(this) class=gb2>Finance</a> <a href="http://translate.google.com/?hl=en&tab=wT" onclick=gbar.qs(this) class=gb2>Translate</a> <a href="http://scholar.google.com/schhp?hl=en&tab=ws" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://blogsearch.google.com/?hl=en&tab=wb" onclick=gbar.qs(this) class=gb2>Blogs</a> <a href="http://www.google.com/realtime?hl=en&tab=wY" onclick=gbar.qs(this) class=gb2>Updates</a> <div class=gb2><div class=gbd></div></div><a href="http://www.youtube.com/?hl=en&tab=w1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?hl=en&tab=wc" class=gb2>Calendar</a> <a href="http://picasaweb.google.com/home?hl=en&tab=wq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?hl=en&tab=wo&authuser=0" class=gb2>Documents</a> <a href="http://www.google.com/reader/?hl=en&tab=wy" class=gb2>Reader</a> <a href="http://sites.google.com/?hl=en&tab=w3" class=gb2>Sites</a> <a href="http://groups.google.com/grphp?hl=en&tab=wg" onclick=gbar.qs(this) class=gb2>Groups</a> <div class=gb2><div class=gbd></div></div><a href="http://www.google.com/intl/en/options/" class=gb2>even more »</a> </div></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><b class=gb4>justinbezanson@gmail.com</b> | <span id=gbe><a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den%26source%3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg" class=gb4>iGoogle</a> | </span><a href="/preferences?hl=en" onclick="this.blur();gbar.tg(event);return !1" aria-haspopup=true aria-owns=gbg class=gb3><u>Settings</u> <small>▼</small></a> | <a href="http://www.google.com/accounts/Logout?continue=http://www.google.com/" class=gb4>Sign out</a><div class=gbm id=gbg><a href="/preferences?hl=en" class=gb2>Search settings</a> <a href="https://www.google.com/accounts/ManageAccount?hl=en" class=gb2>Google Account settings</a> </div></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div></div></div> <center><br clear=all id=lgpd><div id=lga><a href="/search?q=The+Flintstones&ct=flintstones10-hp&oi=ddle"><img alt="50th Anniversary of The Flintstones" title="50th Anniversary of The Flintstones" border=0 height=175 src="/logos/2010/flintstones10-hp.jpg" width=420 id=logo onload="window.lol&&lol()"/></a><br><br></div><form action="/search" name=f><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%> </td><td align=center nowrap><input name=hl type=hidden value=en><input name=source type=hidden value=hp><input type=hidden name=biw><input type=hidden name=bih><div class=ds style="height:32px;margin:4px 0"><input autocomplete="off" maxlength=2048 name=q class="lst" title="Google Search" value="" size=57 style="background:#fff;border:1px solid #ccc;border-bottom-color:#999;border-right-color:#999;color:#000;font:18px arial,sans-serif bold;height:25px;margin:0;padding:5px 8px 0 6px;vertical-align:top"></div><br style="line-height:0"><span class=ds ><span class=lsbb><input name=btnG type=submit value="Google Search" class=lsb></span></span><span class=ds><span class=lsbb><input name=btnI type=submit value="I'm Feeling Lucky" class=lsb></span></span></td><td nowrap width=25% align=left class=sblc><a href="/advanced_search?hl=en">Advanced Search</a><a href="/language_tools?hl=en">Language Tools</a></td></tr></table></form><div style="font-size:83%;min-height:3.5em"><br></div><div id=res></div><span id=footer><center id=fctr><div style="font-size:10pt"><div id=fll style="margin:19px auto 19px auto;text-align:center"><a href="/intl/en/ads/">Advertising Programs</a><a href="/services/">Business Solutions</a><a href="/intl/en/about.html">About Google</a><b><a href="http://www.google.ca/">Go to Google Canada</a></b></div></div><p style="color:#767676;font-size:8pt">© 2010 - <a href="/intl/en/privacy.html">Privacy</a></p></center></span> <div id=xjsd></div><div id=xjsi><script>if(google.y)google.y.first=[];if(google.y)google.y.first=[];google.dstr=[];google.rein=[];window.setTimeout(function(){var a=document.createElement("script");a.src="/extern_js/f/CgJlbiswRTgBLCswWjgALCswDjgALCswFzgALCswJzgALCswPDgALCswUTgALCswWTgPLCswCjiAAUAvLCswFjgALCswGTgALCswITgAQAEsKzAlOM-IASwrMCo4CywrMCs4ESwrMDU4BCwrMEA4ACwrMEE4ACwrME44BiwrMFM4ACwrMFQ4ACwrMFw4GSwrMBg4ACwrMCY4ACyAAheQAh4/2tHRi69JyqA.js";(document.getElementById("xjsd")||document.body).appendChild(a);if(google.timers&&google.timers.load.t)google.timers.load.t.xjsls=(new Date).getTime();},0);google.neegg=1;google.y.first.push(function(){var form=document.f||document.f||document.gs;google.ac.i(form,form.q,'','','yx9rSnVUI7gmA5-dMsqKuA',{o:1,sw:1,l:1,r:0});(function(){function e(){var a=null;if(window.ActiveXObject){a=new ActiveXObject("Msxml2.XMLHTTP");if(!a)a=new ActiveXObject("Microsoft.XMLHTTP")}else if(window.XMLHttpRequest)a=new XMLHttpRequest;return a}function f(a){if(window.execScript)window.execScript(a,"JavaScript");else if(window.eval){var b=null;window.eval("var _et_ = 1;");if(typeof window._et_!="undefined"){delete window._et_;b=true}else b=false;if(b)window.eval(a);else{var d=window.document,c=d.createElement("script");c.type="text/javascript";c.defer=false;c.appendChild(d.createTextNode(a));d.body.appendChild(c);d.body.removeChild(c)}}}function g(a){var b=a;if(b&&b.length>0&&b.substring(0,5)=="throw")b=b.substring(27);f(b)}function h(a){if(a.readyState==4&&(a.status==200||a.status==304))try{g(a.responseText)}catch(b){}}function i(){if(window.google&&!window.google.cp){window.google.cp={};window.google.cp.o={l:"/logos/2010/flintstones10-hp.jpg",h:false,a:"50th Anniversary of The Flintstones",u:"/search?q\x3dThe+Flintstones\x26ct\x3dflintstones10-hp\x26oi\x3dddle",d:true};var a=e();if(a){a.open("GET","/ig/cp/get?hl=en&gl=",true);a.onreadystatechange=function(){h(a)};a.send(null)}}}i();})();;google.mc = [[14,{}],[84,{}],[22,{"m_error":"\u003Cfont color=red\u003EError:\u003C/font\u003E The server could not complete your request.  Try again in 30 seconds.","m_tip":"Click for more information"}],[64,{}],[92,{"avgTtfc":1000,"focus":true,"hpt":250,"optOut":true,"p_dym":"Did you mean:","p_gs":"Google Search","p_sif":"Search instead for","p_srf":"Showing results for","rpt":41,"tdur":50}]];google.med('init');google.History&&google.History.initialize('/')});if(google.j&&google.j.en&&google.j.xi){window.setTimeout(google.j.xi,0);google.fade=null;}</script></div><script>(function(){var b,d,e,f;function g(a,c){if(a.removeEventListener){a.removeEventListener("load",c,false);a.removeEventListener("error",c,false)}else{a.detachEvent("onload",c);a.detachEvent("onerror",c)}}function h(a){f=(new Date).getTime();++d;a=a||window.event;var c=a.target||a.srcElement;g(c,h)}var i=document.getElementsByTagName("img");b=i.length;d=0;for(var j=0,k;j<b;++j){k=i[j];if(k.complete||typeof k.src!="string"||!k.src)++d;else if(k.addEventListener){k.addEventListener("load",h,false);k.addEventListener("error",h,false)}else{k.attachEvent("onload",h);k.attachEvent("onerror",h)}}e=b-d;function l(){if(!google.timers.load.t)return;google.timers.load.t.ol=(new Date).getTime();google.timers.load.t.iml=f;google.kCSI.imc=d;google.kCSI.imn=b;google.kCSI.imp=e;google.timers.load.t.xjs&&google.report&&google.report(google.timers.load,google.kCSI)}if(window.addEventListener)window.addEventListener("load",l,false);else if(window.attachEvent)window.attachEvent("onload",l);google.timers.load.t.prt=(f=(new Date).getTime());})();</script>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...