views:

276

answers:

1

I'm trying to run an $.ajax()-call inside of an dynamicly with jQuery generated iframe. So somehow the jQuery instance needs to get passed into the iframe after it was generated and then then "$.ajax()" must get called... maybe with eval?

So to be clear, not only the iframe should get generated dynamicly, also the content inside the iframe (the JavaScript) should get generated and executed on the fly. And the dynamicly generated JavaScript inside the iframe should be able to use the jQuery instance of the script it was generated by to make use of $.ajax(). Hopefully it's somehow clear what I mean :-)

I'm happy about any suggestions.

A: 

I would suggest creating an iframe dynamically and appending using jQuery. Afer that set src to a basic page you have already created that contains:

<script type="text/javascript">
    $(document).ready(function() {
       $.ajax(...)
    });
</script>

That should ensure that the page fires off your ajax request once it's loaded in the iframe.

hunter