So I have to start this up....why is an iframe "sort of evil"?  It is the
safest way to load a whole page of content without killing the DOM of the
existing page by trying to insert body tags and so on.  Using an iframe you
can use the onLoad method of the iframe to trigger what you want to when you
need to get the element you need. You wouldn't even need to use ajax to do
it, just set the src value for the iframe using script.

-----Original Message-----
From: virtualgadjo [mailto:[email protected]] 
Sent: Monday, 3 May 2010 12:51 AM
To: [email protected]
Subject: Re: [Moo] Re: ajax and the dom


Hi Brook,

please do not use iframe, it's sort of evil except for helping to have
floating elements above Flash and forms :)

except from that, i would add 2 or 3 little other things

- first, of course, assuming all the content you need in the ditant page is
inside a div with an id page for example, you can also send you Ajax request
end then parse it with a regex to send only what is between <div id="page">
and </div><!--/page--> (the comment for your regex to know where is the end
of the right div) Not that difficult :)

- actually, if you wanted to use my little trick for a new website i would
advise you to do it in a simpler way (my suggestion was just for an existing
web site with complete pages already coded)

a better way to implement it would be
- to have a distant php page which only returns the content you need (with a
db request or whatever else) depending on a $_GET var (for htaccess)
- include this page into the content container
- use htaccess to rewrite url (page-home.php, page-products.php and so
on...) so far you have a menu working perfectly without js, but with only
two pages and with SEO urls
- then, with js, parse the url in the href to retreive the right var you
send to the distant page with ajax (home, products...)
- and just update your content div with the HTML result of your request It's
not that far from the way most the cms work...

now, your website works perfectly with and without ajax (something i really
often do and is tiiiiiime and coding saving :))

Have swing
--
View this message in context:
http://mootools-users.660466.n2.nabble.com/Moo-ajax-and-the-dom-tp4991680p49
93175.html
Sent from the MooTools Users mailing list archive at Nabble.com.

Reply via email to