var arr=new Array();
var x=document.createElement("div");
x.setAttribute("id","content");
//url from urls.txt having list of urls
page_request=getContentAjax(url);//AJAX Code
setArrayObject(page_request.responseText);//function defined below
var setArrayObject=function(text){
if (window.location.href.indexOf("http")==-1 || text.status==200)
x.innerHTML=text.responseText;
document.body.appendChild(x);
var n=document.getElementById("name").innerHTML
var cat=document.getElementById("category").innerHTML
var lt=document.getElementById("age").innerHTML
var ln=document.getElementById("dob").innerHTML
var q=Obj.make(n,cat,lt,ln);
arr.push(q);
x.innerHTML=""
}
Present
so now if url is xyz.html, the i'm getting the content of that page through AJAX and loading it to a DIV element(x).....and then accessing the div elements "name","category" etc.,
Problem
but if urls point to heavy pages, it's slow process to do this work.
Expected Solution
so I WANT TO CHECK WHETHER THOSE DIV ID's EXIST IN THAT PAGE OR NOT WITHOUT LOADING THEM and then GET THEIR VALUES IF EXISTS.
You can't. The XMLHTTP request has to wait for all data transmission to end before calling the complete event. So you have to load all the data. You cannot simple call certain elements or partial data w/o server side code.
For example. You could call a PHP script that rips out all data to a certain node level and return the skeleton. Or you could do the whole process on the server side.
That would take some time. You should do some experiments yourself and post here when you find trouble. Its always good to do stuff since you can learn a lot sometimes.
You can start by using something like PHP's simplexml
Bookmarks