that have a demo?
2010/5/2 brook <[email protected]>
> hi all. i am using ajax request and i am having to use a supid
> hackish way to parse the dom so i thought i would ask if there was a
> better way to do it...
>
> below i explain what i have done - but what i want to do is
>
> 1) make an ajax request that loads a different webpage and put that
> into a variable called "page"
> 2) parse the "page" to get particular elements of the dom like this
> page.getElement('myelement')
>
> this is the dumb solution i came up with ....
>
> i have a function that starts like,
>
> function(e,elm,index,grp){
> this.request = e.href
> this.fireEvent("pageRequest")
> var req = new Request({
> url: e.href,
> onSuccess: function(htmlstring) {
> var newpage = new Element('div',{id:
> 'ajaxholder'})
> this.page =
> newpage.set('html',htmlstring)
> ......
>
> the important part is that that an ajax request is made and on success
> i pass the html-string that is returned into a div and pass that to a
> variable named "page".
>
> then to parse then i parse the dom by doing something annoying like...
>
> menu.page.getChildren('div.center')[0].getChildren('div#box')
> [0].getChildren('div#top')[0]
>
> where "menu" is the instance of the class containing the above
> function and the "page" variable.
>
> the page being loaded has all the headers and such of a new page (this
> is important because i want it to degrade nicely if javascript is
> turned off).
>
> so esential i have a div that looks like
>
> <div id="ajaxholder"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
> <html....
>
> obviously this is dumb.
>
> i really want to be able to parse html in the normal way... ie
> menu.page.getElement('top')
>
> i am assuming this is some standard thing i am just missing.
>
> thanks for the help.
> brook
>