Bug Tracker

Modify

Ticket #6479 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

.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

comment:1 Changed 3 years ago by rwaldron

  • Owner set to olafure
  • Priority set to undecided
  • Status changed from new to pending

Please provide a reduced jsFiddle test case, thanks!

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

comment:2 Changed 3 years ago by rwaldron

  • Keywords needsreview added

comment:3 Changed 3 years ago by dmethvin

  • Keywords needsreview removed
  • Status changed from pending to closed
  • Resolution set to duplicate

comment:4 Changed 3 years ago by dmethvin

Duplicate of #6941.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.