Ticket #6479 (closed bug: duplicate)
.load() not using right context
| Reported by: | olafure | Owned by: | olafure |
|---|---|---|---|
| Priority: | undecided | Milestone: | |
| Component: | ajax | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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 :-)
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Please provide a reduced jsFiddle test case, thanks!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.