I was writing some simple AJAX functions for a web page for the migration project.
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http ://w ww.w 3.or g/TR /xht ml1/ DTD/ xhtm l1-s tric t.dt d "> < html xmlns=" http ://w ww.w 3.or g/19 99/x html " xml:lang="en" lang="en"> < head> < link rel="stylesheet" type="text/css" href ="da shbo ard. css" /> < script src="funcs.js"> < /script> < meta http -equ iv=" Cont ent- Type " content="text/html; charset=iso-8859-1"> < /meta> < title> title< /title> < /head>
var component
function request(attribute, value, comp) { try { xmlhttp = wind ow.X MLHt tpRe ques t?ne w XMLHttpRequest(): new Acti veXO bjec t("M icro soft .XML HTTP "); } catch(e){ docu ment .get Elem entB yId( "mai n"). inne rHTM L = "BROWSER DOES NOT SUPPORT AJAX"; } component = comp; xmlh ttp. onre adys tate chan ge = loadResult; url=attribute + "=" + value; url=url+"& sid= "+Ma th.r ando m(); xmlhttp.open("GET", url); xmlhttp.send(null); }
function loadResult() { // if the readyState = 4 = Completed // & http status is 200, get responseText if ((xm lhtt p.re adyS tate == 4) & & (xmlhttp.status == 200)) { docu ment .get Elem entB yId( comp onen t).i nner HTML = xmlh ttp. resp onse Text ; }
else { docu ment .get Elem entB yId( comp onen t).i nner HTML = "Loading..."; } }
< span id="result"> response goes here! < /span>
requ est( "myA tt", "myv alue ","r esul t");
No comments:
Post a Comment