i'm constructing a multi-language supporting webpage.
every piece of text is put in a large javascript array which is called by the user when opening the webpage. so far so good.
when I now use an Ajax-function to change the content of a certain <div>, which's content is in an external.php (in fact, ajax changes this php),
i want to make this change appear directly to the viewer (me) without reloading.
so i call again Ajax to get the content of this external.php to re-place it into the <div>.
but the problem now: by doing this, the language-support functions are not evaluated.
every text-piece in the source code looks like this:
Expand|Select|Wrap|Line Numbers
- <script>document.write(lang[int]);</script>
i tried to replace the <script>'s with the array's content using this:
Expand|Select|Wrap|Line Numbers
- body = xmlhttp.responseText;
- body = body.replace(/<script>document\.write\(lang\[(.+?)\]\)\;<\/script>/, lang[$1] );
Expand|Select|Wrap|Line Numbers
- "lang[$1]" //it replaces the string "lang[$1]" with the right integer as $1
- lang[$1] //it says $1 not defined (of course...)
- lang["$1"] //it replaces with "undefined" because lang["$1"] doesnt exist
is there maybe a better way to enforce the source-code from responseText to first evaluate its javascripts before placing into the <div> ?
best wishes
vindex