Skip to main content

Bug Tracker

Side navigation

#14524 closed bug (notabug)

Opened November 08, 2013 01:50AM UTC

Closed November 16, 2013 02:33AM UTC

Last modified December 19, 2013 11:37PM UTC

jQuery's Ajax interferes after adding jQuery script to an inner iframe

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

In this example, attempting to jQuery.ajax or jQuery.get causes the outer window's jQuery variable to get replaced - the jQuery.dialog and any other plugins to jQuery are no longer there. (It happens in 1.9.1 and 1.10)

    <link rel="stylesheet" href="" />
    <script src=""></script>
    <script src=""></script>

Try and <button id="btn">load</button>
<iframe width=300 height=300></iframe>

"use strict";
    var $ = jQuery;
    console.log(typeof jQuery('iframe').dialog);
    var doc = jQuery('iframe')[0].contentDocument;
    function insertscript(src) {
        var newscript = doc.createElement('script');
    //This breaks the jQuery:
    var test = $.get('',function(){
        //Now we know jQuery should be in the frame.
    //So does this:
    console.log(typeof jQuery('iframe').dialog);
        //jQuery is no longer the original jQuery object. Note the cached reference $().dialog does exist though.
        console.log('after awhile... dialog is ' + typeof jQuery('iframe').dialog);
Attachments (0)
Change History (6)

Changed November 10, 2013 12:52AM UTC by m_gol comment:1

owner: → anonymous
status: newpending

What is this bug about? Why are you downloading a second copy of jQuery via the first one?

Changed November 16, 2013 02:13AM UTC by anonymous comment:2

status: pendingnew

Looks like the real bug here is that jQuery.ajax documentation mentions that the fetched data will be ''run'', if it is a script, but jQuery.get has no mention of this. This should be a big bold item in my opinion, people will wonder why it's immediately running the script, especially if it only does so same-domain.

Changed November 16, 2013 02:33AM UTC by dmethvin comment:3

resolution: → notabug
status: newclosed

Notice that the first thing the jQuery.get)() docs do is tell you the equivalent jQuery.ajax() call. So, an astute reader could know that they need to read those docs. Or we could copy and duplicate a big chunk of docs into the ajax shorthand methods but that just makes maintenance harder.

Changed November 16, 2013 02:00PM UTC by scottgonzalez comment:4

Or we could copy and duplicate a big chunk of docs into the ajax shorthand methods but that just makes maintenance harder.

We already have a solution for that problem: XML Includes.

Changed November 16, 2013 02:20PM UTC by dmethvin comment:5

Now break up all the ajax options and discussion text into include-able parts and determine which are applicable for each of the .get/.post/.load shortcut methods.

Changed December 19, 2013 11:37PM UTC by anonymous comment:6

Yeah that explains a lot