Revision: 2587
Updated Code
at March 14, 2007 08:50 by 1man
Updated Code
function basicAJAX(file) {//pass a variable into the function var request = getHTTPObject(); if(request){ request.onreadystatechange = function() { displayResponse(request); }; request.open("GET", file, true);//this is where the var is picked up, the location request.send(null); } } function displayResponse(request) { if(request.readyState == 4){//waits for the complete before execute. if(request.status == 200 || request.status == 304){ alert(request.responseText);//this is what happens once complete //for XML //var data = request.responseXML;//the while document is now in this variable. Travesrse it using the DOM. //createInfo(data);//function runs and references the DOM } else { alert("Something Broke!"); } } } function prepareLinks(){ if(!document.getElementsByTagName) return false; var allLinks = document.getElementsByTagName("a"); for(i=0;i<allLinks.length;i++){ allLinks[i].onclick = function() { basicAJAX(this.href); return false; } } }
Revision: 2586
Updated Code
at March 13, 2007 07:24 by 1man
Updated Code
function basicAJAX(file) {//pass a variable into the function var request = getHTTPObject(); if(request){ request.onreadystatechange = function() { displayResponse(request); }; request.open("GET", file, true);//this is where the var is picked up, the location request.send(null); } } function displayResponse(request) { if(request.readyState == 4){//waits for the complete before execute. if(request.status == 200 || request.status == 304){ alert(request.responseText);//this is what happens once complete //for XML //var data = request.responseXML;//the while document is now in this variable. Travesrse it using the DOM. //createInfo(data);//function runs and references the DOM } else { alert("Something Broke!"); } } } function prepareLinks(){ if(!document.getElementsByTagName) return false; var allLinks = document.getElementsByTagName("a"); for(i=0;i<allLinks.length;i++){ allLinks[i].onclick = function() { basicAJAX(this.href); return false; } } }
Revision: 2585
Updated Code
at March 13, 2007 07:22 by 1man
Updated Code
function basicAJAX(file) {//pass a variable into the function var request = getHTTPObject(); if(request){ request.onreadystatechange = function() { displayResponse(request); }; request.open("GET", file, true);//this is where the var is picked up, the location request.send(null); } } function displayResponse(request) { if(request.readyState == 4){//waits for the complete before execute. if(request.status == 200 || request.status == 304){ alert(request.responseText);//this is what happens once complete var data = request.responseXML;//the while document is now in this variable. Travesrse it using the DOM. createInfo(data);//function runs and references the DOM } else { alert("Something Broke!"); } } } function prepareLinks(){ if(!document.getElementsByTagName) return false; var allLinks = document.getElementsByTagName("a"); for(i=0;i<allLinks.length;i++){ allLinks[i].onclick = function() { basicAJAX(this.href); return false; } } }
Revision: 2584
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 13, 2007 05:14 by 1man
Initial Code
function basicAJAX(file) {//pass a variable into the function var request = getHTTPObject(); if(request){ request.onreadystatechange = function() { displayResponse(request); }; request.open("GET", file, true);//this is where the var is picked up, the location request.send(null); } } function displayResponse(request) { if(request.readyState == 4){//waits for the complete before execute. if(request.status == 200 || request.status == 304){ alert(request.responseText);//this is what happens once complete } else { alert("Something Broke!"); } } } function prepareLinks(){ if(!document.getElementsByTagName) return false; var allLinks = document.getElementsByTagName("a"); for(i=0;i<allLinks.length;i++){ allLinks[i].onclick = function() { basicAJAX(this.href); return false; } } }
Initial URL
Initial Description
Very basic grab a line of text from a file then display it in an alert box. Uses other functions for loading prepareLinks() and creating the request.
Initial Title
Grab Text from a File Ajax
Initial Tags
ajax, function
Initial Language
JavaScript