www.webdeveloper.com
Results 1 to 4 of 4

Thread: Checking element existance in foreign page

Hybrid View

  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Question Checking element existance in foreign page

    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.

    Any one please help out. Thanks in advance

  2. #2
    Join Date
    Jul 2007
    Posts
    386
    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.

  3. #3
    Join Date
    Jun 2010
    Posts
    2
    Thanks for the reply, can you please specify some example showing how to do that in php as you said and how to do it on serverside.

  4. #4
    Join Date
    Jul 2007
    Posts
    386
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles