Dysan Posted February 7, 2008 Share Posted February 7, 2008 Hi, I am keen to study how Ajax is coded, could anybody give me some simple Ajax code to tear apart, that retrieves data from a database and displays it on the screen? Quote Link to comment Share on other sites More sharing options...
priti Posted February 8, 2008 Share Posted February 8, 2008 well you can google a lot of tutorials . There is one on w3schools http://www.w3schools.com/ajax/ajax_database.asp Quote Link to comment Share on other sites More sharing options...
shankar23 Posted April 19, 2008 Share Posted April 19, 2008 in Ajax only xmlHttp is main part... It will be used everywhere if Ajax exists... So just learn how to pass variable to PHP or any scripting languages... It will be usefull for you in future.. Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted April 30, 2008 Share Posted April 30, 2008 I use frameworks only these days for my ajax funtionality prototype and and mootools do a great job with this. It makes you able to write a few simple lines instead of using the usually long script. for example instead of using this which is a pain to modify for starters and i know i have been there var xmlHttp function showCustomer(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="getcustomer.asp"; url=url+"?q="+str; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } you can use this //when the button start is clicked the ajax function will start $('start').addEvent('click', function(e) { e = new Event(e).stop(); //the external page that will be loaded var url = "http://demos.mootools.net/demos/Ajax/lipsum.html"; /** * The simple way for an Ajax request, use onRequest/onComplete/onFailure * to do add your own Ajax depended code. */ new Ajax(url, { method: 'get', update: $('log')//the element log that will be updated <div id="log"></div> }).request(); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.