#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: | ||
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 :-)
Change History (4)
comment:1 Changed 12 years ago by
Owner: | set to olafure |
---|---|
Priority: | → undecided |
Status: | new → pending |
comment:2 Changed 12 years ago by
Keywords: | needsreview added |
---|
comment:3 Changed 12 years ago by
Keywords: | needsreview removed |
---|---|
Resolution: | → duplicate |
Status: | pending → closed |
Please provide a reduced jsFiddle test case, thanks!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.