I am using jQuery to create an ajax request and everything works as expected. But he evaluates the scenarios in the wrong context.
I have an iframe (same domain, no worries here), and I'm trying to get the scripts for eval in the iframe context, instead of where the ajax request was made - for example. another frame.
I thought I could say ajax so as not to analyze the scripts, and I would do the work myself to evaluate them in the right context. Any ideas or ways to turn off automatic pricing?
Edit
So, I was somewhat wrong with the original question. Scripts are not evaluated when loading, but rather when content is placed in a document. You can see this by checking an example:
$('#some_element').html('<span>content</span><script>alert(window)</script>');
Now, when you do this from another frame, the evaluation takes place in the area where you are calling, and not in the element into which you are inserting content.
I ended up setting the content without using jQuery, and then discovered / rejected the script tags:
element.get(0).innerHTML = data; element.find('script').each(function() { otherWindow.eval(this.innerText); });
Final update
I ended up tracking it to the source and canceled it from there. The next one is coffeescript, but you can get this idea. I decided to override it, because for my use this should never happen in the top window, but is expected in the iframe content.
$.globalEval = (data) -> (iframeWindow.execScript || (data) -> iframeWindow["eval"].call(iframeWindow, data))(data) if (data && /\S/.test(data))