Forum Moderators: open

Message Too Old, No Replies

Best way to use AJAX to receive a page that has HTML and Javascript?

         

Parlays

7:37 pm on Mar 27, 2009 (gmt 0)

10+ Year Member



Hello everybody!

I'm hoping to hear from some experienced AJAX experts out there the best way to handle situations where you are making an AJAX call to a page that contains HTML and Javascript. I am using jQuery and I know jQuery automatically runs eval on the javascript.

It all works fine and I have been using it. But I hear alot that using eval() is bad. I also know that I could set up the javascript in the page that is making the AJAX call (if I know what the javascript is ahead of time). I guess I really want to know what the best way is to hanlde these AJAX situations where you are not only receiving HTML but also getting some javascript?

Thanks!

whoisgregg

8:48 pm on Mar 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



eval() is considered dangerous if you don't have control over what is being eval()'d. Basically, if you are generating your own HTML/Javascript pages, then you don't have anything to fear.

However, if you are running eval on data from a server outside your control, you should have a *high* degree of trust with that source.