Bug Tracker

Modify

Ticket #6034 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

getScript doesn't always respect the base tag

Reported by: bhasden Owned by:
Priority: major Milestone: 1.4.2
Component: ajax Version: 1.4.1
Keywords: Cc:
Blocking: Blocked by:

Description

I've got a website with the <base> tag defined as the website root directory, for example:  http://www.example.com/myWebsite/.

In IE8 when I use $.getScript('path/to/script.js') jQuery appropriately requests and loads  http://www.example.com/myWebsite/path/to/script.js no matter where the current page is located in the website.

On the other hand, in FF 3.5.7 the request for 'path/to/script.js' is relative to the current page. For example if I'm viewing  http://www.example.com/myWebsite/post/345/ the getScript call will request  http://www.example.com/myWebsite/post/345/path/to/script.js.

I understand this may not be a bug with jQuery but since jQuery usualy insulates me from these sort of issues it would be nice if jQuery found a way of forcing getScript to behave one way or the other.

Attachments

getScript_bug.html Download (302 bytes) - added by bhasden 3 years ago.
This html file demonstrates the issue. No matter where the file is located in the website it should always request  http://localhost/path/to/script.js. The bad behavior comes in when the file is located in a directory underneath the root. IE8 will continue to request the appropriate file while FF3.5 disregards the base tag and requests the script relative to the page url.

Change History

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to invalid
  • Component changed from unfilled to ajax

Do you have a simple test page that we can look at? We're just using the native XMLHttpRequest here so figuring out the difference would be ideal.

Changed 3 years ago by bhasden

This html file demonstrates the issue. No matter where the file is located in the website it should always request  http://localhost/path/to/script.js. The bad behavior comes in when the file is located in a directory underneath the root. IE8 will continue to request the appropriate file while FF3.5 disregards the base tag and requests the script relative to the page url.

comment:2 Changed 3 years ago by bhasden

Is there any way jQuery could be updated to pull the base tag href before making the XHR so that it could pull together the absolute url if a base tag exists? I know this isn't the most pressing issue in the world but it's really annoying that the behavior is different between the two major browsers, especially since jQuery is designed to provide consistent cross-browser behavior.

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.