Revision: 2613
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 14, 2007 09:32 by 1man
Initial Code
/*Executed on click. Passes the url to the function. Function opens the URL then
*the parseResponse function is called
*/
function grabFile(file) {
var request = getHTTPObject();
request.onreadystatechange = function() {
parseResponse(request);//this is what happens once complete
}
request.open("GET",file,true);
request.send(null);
}
/*Once the request state is complete and the file exists, it grabs the results
* div, and inserts the response text and innerHTML.
*/
function parseResponse(request) {
if(request.readyState == 4){
if(request.status == 200 || request.status == 304){
var results = document.getElementById("results");
results.innerHTML = request.responseText;
} else {
alert("Something Broke!");
}
}
}
Initial URL
Initial Description
Simply replaces the div's innerHTML with the response text received from the file.
Initial Title
Pull in Info from a HTML File using innerHTML
Initial Tags
ajax, file, html, DOM
Initial Language
JavaScript