jQuery Form plugin with <script> returned
I'm using the Form plugin for handling file uploads, and it's working perfectly, except for one snag. If I return some <script> items with jQuery code in them to be executed, I get "$ is undefined" errors. I've determined that this is because the response is going into an iframe, where jQuery is not loaded.
I tried to wrap everything in <!-- ... --> and let the success or dataFilter callback strip that off, but then the innerHTML test in the cb function always fails, because comments are not returned by that.
I also considered removing the <script> tags and adding them in one of the callbacks, but that's not a good option either, as some of them are automatically generated by the PHP framework I'm using, and it would be very hackish to strip them back off. This is still on the table as a last resort, but I'm hoping there's a better solution.
A similar solution would be to translate <script> into <scr> or some such invalid tag on the server side, and back to <script> in the callback.
The other possibility I see is to make the HTML sent back to the iframe a whole page, with headers and everything, including loading jQuery, and then having that somehow reference back into the main page. But I'm not sure how to go about building those references, plus it seems like it would be a performance hit to have the browser load jQuery for every such request.
Any options I haven't considered, or ways to tweak the Form plugin to Do The Right Thing?