This is a discussion on Importing Javascript from an AJAX call within the AJAX Implementation forums, part of the Advanced Ajax category; Hi all I am using AJAX to return the content of another page and then I put the returned content into the innerHTML of a div on the calling page. ...
|
|||||||
|
|
#1 (permalink) |
|
Junior Member
Join Date: May 2009
Posts: 1
Rep Power: 0 ![]() |
Importing Javascript from an AJAX call
Hi all
I am using AJAX to return the content of another page and then I put the returned content into the innerHTML of a div on the calling page. I use this for example when asking a user to complete a form. My issue is if I define a javascript function in the page I'm calling with JavaScript, it will not be available on the page I have my div on (the calling page). My solution for this is to extract the javascript functions from the content returned by the AJAX call and "import" it into the calling page using eval. This solution does work, but I'm curious if there is not a better way to handle this, as it appears the eval might be causing a memory leak if called too often. Please let me know if you have any suggestions. |
|
|
|
| Sponsored Links | |
|
|
#2 (permalink) |
|
Junior Member
Join Date: Jul 2009
Posts: 3
Rep Power: 0 ![]() |
As a secondary 'warning' about using .innerHTML to load a div, be aware that the various browsers do this differently, and most do not rescan the imported html and update the dom tree (or do it badly). You also may get errors if running in STRICT mode on IE since it seems to want to translate all the new tags to upper case.
|
|
|
|
![]() |
| Bookmarks |
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to call a servlet from jsp using ajax | Preethi | AJAX Help | 0 | 02-12-2009 08:03 AM |
| Importing XML into MySQL table? | multiz_com | XML and XSLT | 0 | 06-10-2007 03:35 PM |