I added a simple ajax link inside a view. This does nothing but invoke an action that in turn renders, through partial render a page with a simple javascript alert.
I set the fourth parameter of partial rendering to true to indicate that it should process the result.
The ajax call is successful but the Javascript code is not interpreted.
I had a similar problem a while back. I never really came to a firm reason as to why it was happening, I think that jQuery was stripping the script tags from what it was inserting… My solution was to return the HTML and Javascript as parts of a JSON object and process them independently, which I chose as it allowed me to update multiple parts of the page with a single AJAX request, but that might not be everyone’s cup of tea.
I’d use some form of dev tools to figure-out if the JavaScript is actually being included. If it is, I’d next look at where it is in the code. Firebug’s Net tab, if open, will show you the transfers and can be used to inspect the content of AJAX responses, the network tab in Chrome’s Developer Tools has much the same purpose.
Note that, if it’s in the $(document).ready(), remember that this function won’t be called by default as the document was ready ages ago, and you may not want to call it again as you may end-up doubling-up event handlers of what is already on the page.