tmh766 Posted February 11, 2010 Share Posted February 11, 2010 Hi everyone. I have never done anything like this and can't seem to figure out a solution. I have a page with a div whose content is reassigned onclick by way of an Ajax request. Here is the part I can't figure out. The div's content (a bunch of text comments and a reply box) uses JavaScript to move the reply box up and down to each comment when clicked, and more importantly, to set an ID variable, in the form (which contains the comments and reply box) so when posted, the server knows which comment is being replied to. Does anyone have an idea on how I can get the JavaScript within the returned text from the Ajax request to be evaluated? I can't seem to figure out a way. The Ajax request and is completed successfully, the returned HTML snippet is evaluated and rendered, but not the JavaScript that accompanies it. Thanks a lot for your time, I would greatly appreciate any insight on this problem, Tim Quote Link to comment Share on other sites More sharing options...
tmh766 Posted February 11, 2010 Author Share Posted February 11, 2010 Oops this should be in the Ajax Section can someone move it? I apologize. Quote Link to comment Share on other sites More sharing options...
yozyk Posted February 11, 2010 Share Posted February 11, 2010 add to html received by way of an Ajax request the function <script type="text/javascript"> var ajax_func = function () { // place your code here } </script> and call this function, when the html code loaded in div or use JSON/eval Quote Link to comment Share on other sites More sharing options...
tmh766 Posted February 11, 2010 Author Share Posted February 11, 2010 Can you explain more please? Quote Link to comment Share on other sites More sharing options...
yozyk Posted February 11, 2010 Share Posted February 11, 2010 Do you want to eval JS code from ajax data? Quote Link to comment Share on other sites More sharing options...
tmh766 Posted February 11, 2010 Author Share Posted February 11, 2010 Yes but it is mixed with HTML, it is not just Javascript. I think I will investigate another way to complete this rather than having to deal with parsing it out. Quote Link to comment Share on other sites More sharing options...
yozyk Posted February 11, 2010 Share Posted February 11, 2010 Show me the code snippet (JS mixed with HTML). Quote Link to comment Share on other sites More sharing options...
tmh766 Posted February 11, 2010 Author Share Posted February 11, 2010 Thank you for helping, but I ended up just eliminating the variables sent by ajax. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.