Quantcast

JavaScript not executing in ajax response

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

JavaScript not executing in ajax response

Dean Del Ponte-2
  1. User clicks a button which initiates an ajax request to the server
  2. My controller handles the request, and renders a template as the response
  3. The template contains JavaScript
  4. The JavaScript does not execute when rendered to the client
Any ideas why JavaScript contained within a template is not executed when rendered via Ajax?

Thanks!

- Dean Del Ponte
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JavaScript not executing in ajax response

sethfuller
The callback function, just receives the text rendered. It doesn't try to execute any Javascript inside it. In your callback function after putting your rendered content into the DOM, you could probably call the Javascript function though. I have rendered a template containing  a YUI autocomplete input box with Javascript attached and that gets called when the user types in the new autocomplete so the Javascript can be called.
Loading...