Skip to main content

Bug Tracker

Side navigation

#9059 closed bug (invalid)

Opened May 03, 2011 11:05AM UTC

Closed May 20, 2011 08:09AM UTC

Last modified July 14, 2011 06:24PM UTC

Incorrect URL using $.ajax for GET with empty value in data

Reported by: Thomas Owned by: Thomas
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:
Description

When using $.ajax and an undefined value s part of the data property, the URL produced does not include the key-part.

 $.ajax({
        type: 'GET',
        url: 'http://example.com/SomePage',
        data: {'MyKey': 'value', 'OtherKey': undefined, 'ThirdKey': ''}
    });

Does not include 'OtherKey' in the URL

Expected URL would be http://example.com/SomePage?MyKey=MyValue&OtherKey=&ThirdKey=

ActualURL is http://example.com/SomePage?MyKey=MyValue&ThirdKey=

Fiddle: http://jsfiddle.net/QKmtz/3/

Tested on 1.4.4, 1.5.2 and Edge (fiddle)

Attachments (0)
Change History (5)

Changed May 03, 2011 07:02PM UTC by dmethvin comment:1

owner: → Thomas
status: newpending

When you say "expected", is there some governing spec for this behavior? Or are you just saying you expected to be able to pass undefined values and have jQuery do something useful with it?

Changed May 04, 2011 01:04PM UTC by Thomas comment:2

status: pendingnew

Replying to [comment:1 dmethvin]:

When you say "expected", is there some governing spec for this behavior? Or are you just saying you expected to be able to pass undefined values and have jQuery do something useful with it?

I was unable to find anything in the $.ajax doc, or in the jquery source by looking quickly.

It was "my" expected behaviour, based on the $.param documentation

Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.

Therefore, I assumed the expected behavior would be identical.

Changed May 05, 2011 01:55PM UTC by dmethvin comment:3

status: newpending

I'm inclined to close this wontfix then. How are the properties getting an undefined value?

Changed May 20, 2011 08:09AM UTC by trac-o-bot comment:4

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Changed July 14, 2011 06:24PM UTC by Thomas comment:5

Replying to [comment:3 dmethvin]:

I'm inclined to close this wontfix then. How are the properties getting an undefined value?

(I'm the original poster)

IIRC the undefined values were computed on clientside, and correct from a application-logic point of view.

Assuming the current behaviour is as expected, I feel "something" is misleading/confusing as $.param "is suitable for use in a URL ...." and has different behaviour than $.ajax.

It just seems inconsistent.

(Oh, and sorry for the very very late followup. )