Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6034 closed bug (invalid)

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:
Blocked by: Blocking:

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 (1)

getScript_bug.html (302 bytes) - added by bhasden 10 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.

Download all attachments as: .zip

Change History (3)

comment:1 Changed 10 years ago by john

Component: unfilledajax
Resolution: invalid
Status: newclosed

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 10 years ago by bhasden

Attachment: getScript_bug.html added

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 10 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.

Note: See TracTickets for help on using tickets.