Skip to main content

Bug Tracker

Side navigation

#6479 closed bug (duplicate)

Opened April 25, 2010 12:43PM UTC

Closed November 05, 2010 02:07AM UTC

Last modified November 05, 2010 02:07AM UTC

.load() not using right context

Reported by: olafure Owned by: olafure
Priority: undecided Milestone:
Component: ajax Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

Consider the following example of using jQuery (version 1.4.2) in a Firefox (version 3.6.3 on WinXP) in an extension.

--- code start ---

// contentDocument is the currently loaded web page DOM

$tmpData = jQuery('<div/>', contentDocument);

We need to let jQuery use the XMLHttpRequest object from the contentDocument's window, otherwise we'll get "Permission Denied" error.

jQuery.extend(jQuery.ajaxSettings,

{xhr: function() {

return new contentDocument.defaultView.XMLHttpRequest();

}

});

$tmpData.load('http:some.page.net/ p.interesting');

--- code end ---

Now, this doesn't work, because of line 4832, "jQuery("<div />")"

That statement creates a temporary div tag to load the data into, but the div is creates in default context, which in a extension is the brower environment, not the webpage's.

If i modify the .load function:

load: function( url, params, callback, context ) {

and the line in question to:

jQuery("<div />", context)

Things start to work.

Now, perhaps I'm doing this in a too complex way, but unless there is a way to set the context when that temporary element is creates, it's a bug in my opinion :-)

Attachments (0)
Change History (4)

Changed October 29, 2010 04:53PM UTC by rwaldron comment:1

owner: → olafure
priority: → undecided
status: newpending

Please provide a reduced jsFiddle test case, thanks!

Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.

Changed October 29, 2010 05:03PM UTC by rwaldron comment:2

keywords: → needsreview

Changed November 05, 2010 02:07AM UTC by dmethvin comment:3

keywords: needsreview
resolution: → duplicate
status: pendingclosed

Changed November 05, 2010 02:07AM UTC by dmethvin comment:4

Duplicate of #6941.