J
Joel Byrd
I want a website that works in the following way: It has a main
content div, and of course menu items. When you click a menu item, it
should use AJAX to change the main content div to the content of the
page of the menu item you clicked. So, for example, if you clicked
"About Us", then in the main content div, you would see the content of
the about us page. Now, this is pretty simple if the content of a
given page is just text (I just get the content of the page and set the
innerHTML property of the div to this content - I know there are
different opinions on the Kosherness of innerHTML, but...). But the
rub lies when the page that I want to fill the main content with
contains more than just simple html. For example, it is a contact form
and it contains some javascript for client-side form validation. It
gets a little icky when I'm trying to dynamically load javascript using
AJAX (in other words, it doesn't work - either the responseText is
invalid or the status returned is not 200, and I know this because the
code is not getting past the following condition: if
(http.responseText.indexOf('invalid') == -1 && http.status == 200)...
Are there any thoughts on using AJAX to dynamically load content on the
fly that is more than just plain html (I guess this means at least
javascript)? Is this just a really bad idea to begin with, are there
decent methods of doing this, etc...
content div, and of course menu items. When you click a menu item, it
should use AJAX to change the main content div to the content of the
page of the menu item you clicked. So, for example, if you clicked
"About Us", then in the main content div, you would see the content of
the about us page. Now, this is pretty simple if the content of a
given page is just text (I just get the content of the page and set the
innerHTML property of the div to this content - I know there are
different opinions on the Kosherness of innerHTML, but...). But the
rub lies when the page that I want to fill the main content with
contains more than just simple html. For example, it is a contact form
and it contains some javascript for client-side form validation. It
gets a little icky when I'm trying to dynamically load javascript using
AJAX (in other words, it doesn't work - either the responseText is
invalid or the status returned is not 200, and I know this because the
code is not getting past the following condition: if
(http.responseText.indexOf('invalid') == -1 && http.status == 200)...
Are there any thoughts on using AJAX to dynamically load content on the
fly that is more than just plain html (I guess this means at least
javascript)? Is this just a really bad idea to begin with, are there
decent methods of doing this, etc...