Opened 14 years ago
Closed 14 years ago
#4498 closed feature (fixed)
unexpected redirect in jQuery.extend function
Reported by: | oluckyman | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | core | Version: | 1.3.2 |
Keywords: | extend | Cc: | |
Blocked by: | Blocking: |
Description
i have post request:
$.post( this.loggerUrl, {url:this.url, action:action, timestamp:date.getTime()} )
where this.url == document.location
$.post -> $.ajax -> s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
and inside jQuery.extend we have line 604:
else if ( copy !== undefined)
target[ name ] = copy;
in this line we have redirect, when target == location and name == "href".
in my own script i'm fix it by replacing
$.post( this.loggerUrl, {url:this.url, action:action, timestamp:date.getTime()} )
to
$.post( this.loggerUrl, {url:this.url.toString(), action:action, timestamp:date.getTime()} )
but how about other users? i spent one hour before found this feature -)
--
(sorry for my english)
Change History (3)
comment:1 follow-up: 2 Changed 14 years ago by
comment:2 Changed 14 years ago by
Replying to dmethvin:
Wow, I'm sure that was a pain to diagnose. I can see why it is happening though. The
url
parameter should be aString
:http://docs.jquery.com/Ajax/jQuery.ajax#options
However,
document.location
is not a string. It's a Location object with properties like.href
and methods like.toString()
https://developer.mozilla.org/en/DOM/document.location
If you said
url: document.location.href
it should work fine.
Thanx for reply. I'm have fix it as you say.
BUT, I do not think, that this feature is good-) Maybe explicitly convert "key/value pairs" inside jQuery.extend
function? Or describe this unexpected behaviour in documentation? with large letters and red color: "DEVELOPER! PLEASE, CONVERT READONLY OBJECTS TO STRING, BEFORE PASS IT TO JQUERY FUNCTIONS" -))
comment:3 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
I updated the docs to make it clearer.
Wow, I'm sure that was a pain to diagnose. I can see why it is happening though. The
url
parameter should be aString
:http://docs.jquery.com/Ajax/jQuery.ajax#options
However,
document.location
is not a string. It's a Location object with properties like.href
and methods like.toString()
https://developer.mozilla.org/en/DOM/document.location
If you said
url: document.location.href
it should work fine.