Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2007
    Location
    Chennai, Tamil Nadu, India
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    how to run script in responseText

    Hi,
    My script requests dynamic content from the server using ajax. it contains javascript code and i am assigning it to an elements inner html. i want to execute the javascript in the elements innerhtml... that is when the response text is ready and when it is assigned as inner html it would be nice if any javascript code in it is executed... would that be possible?
    http://vikku.info/
    - யானைக்கும் அடிசறுக்கும்

  • #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    I do not know how your response is like, but if it is a valid javascript you can try executing it like this:

    eval(myAjax.responseText);

  • #3
    New Coder
    Join Date
    Jan 2007
    Location
    Chennai, Tamil Nadu, India
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    yes ok

    hi,
    i will try that. anyway... what if my code is like the following

    <div>
    ...
    <script>
    ...
    </script>
    ....
    </div>

    my be i should not have scripts like this instead i should have it in the main page or included it in the main page... ain't it?

    anyway thank you.
    http://vikku.info/
    - யானைக்கும் அடிசறுக்கும்

  • #4
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    Yes sure put your script outside the body.

  • #5
    New Coder
    Join Date
    Jan 2007
    Location
    Chennai, Tamil Nadu, India
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    i would like to ask another question

    hi,
    how about this but not related to the above... anyway i will post this as a new thread but i thought you could answer...

    <iframe>
    <doc type>
    <html>
    .....
    </html>

    from the above you can see that an iframe is inserted above all code...
    also there were injection in between the code...

    for the latter i used javascript remove iframes but i tried for 10 mins to remove the first top iframe and i havent completed that yet...

    meanwhile if i could get an answer then i can upload the file to my clients...

    there has been a hack through ftp's and have requested to change the password but before that i dont want those pages to include iframes...

    hope you can get my point...

    how to remove any html element dynamically using javascript which is outside the body tag or the total code...

    i can use object.parentNode.removeChild(object)...
    this works fine...

    i used document.removeChild(firstobject)... not a success...

    any idea ?
    http://vikku.info/
    - யானைக்கும் அடிசறுக்கும்


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •