Bug Tracker

Modify

Ticket #5786 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

xhr.send should test if data property is undefined

Reported by: rschouten Owned by:
Priority: minor Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

When using the $.ajax method with type 'POST' or 'DELETE' (probably other types too) and the data property is undefined, the string "undefined" appears in the request's payload. Normally this does not matter but in certain circumstances,like working with 3rd party APIs, this can lead to errors.

If sending 'undefined' as a string is not intentional, the data property should be tested and only sent if it is defined.

For example, at line 3633 of file  http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js the code could be changed to:

if (s.data === undefined) {

xhr.send();

} else {

xhr.send(s.data);

}

Attachments

index.html Download (665 bytes) - added by rschouten 4 years ago.
HTML with ajax to perform an HTTP DELETE

Change History

Changed 4 years ago by rschouten

HTML with ajax to perform an HTTP DELETE

comment:1 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in 1.4.3

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.