Hi everyone,
You should have encounter this one, i m quite sure someone will be able to help on this one...! ;-)
I want to call a php script with clean ajax and load the generated code in a div: Here is my distant script named ajax_test.php:
<script type="text/javascript"> document.write("Bonjour" ); </script>
As you can see in fact this script onlt contain JS code. My pb is that the code is well loaded in the targeted div but not interpreted...
I know there is a kind of cheat to do with the eval() function but i do not know where to place it...
I really need to know how to interprete Generated js code.
So can someone help me?
Thanks by advance!
You can generate all JavaScript statements at server-side and then you can append it to your document DOM.
The trick is that the JavaScript cannot be placed inside any tag, but in the document body or head.
For example suppose that I generated the code at server-side:
alert("Hello World");
I have to place it inside a <script> tag:
<script> alert("Hello World");</script>
And then insert it as child of document body or head (as a immediate child not inside other tag).
Log in to post a comment.
Hi everyone,
You should have encounter this one,
i m quite sure someone will be able to help on this one...!
;-)
I want to call a php script with clean ajax and load the generated code in a div:
Here is my distant script named ajax_test.php:
<script type="text/javascript">
document.write("Bonjour" );
</script>
As you can see in fact this script onlt contain JS code.
My pb is that the code is well loaded in the targeted div
but not interpreted...
I know there is a kind of cheat to do with the eval() function but i do not know where to place it...
I really need to know how to interprete Generated js code.
So can someone help me?
Thanks by advance!
You can generate all JavaScript statements at server-side and then you can append it to your document DOM.
The trick is that the JavaScript cannot be placed inside any tag, but in the document body or head.
For example suppose that I generated the code at server-side:
alert("Hello World");
I have to place it inside a <script> tag:
<script> alert("Hello World");</script>
And then insert it as child of document body or head (as a immediate child not inside other tag).