Bug Tracker

Modify

Ticket #4851 (closed bug: fixed)

Opened 3 years ago

Last modified 20 months ago

Inside ajax callback function (success, error), 'this' context does not retain 'data' property consistently/correctly

Reported by: rtaylor Owned by:
Priority: major Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: ajax callback Cc:
Blocking: Blocked by:

Description

Inside ajax callback function (success, error), 'this' context does not retain 'data' property consistently/correctly.


USING A GET:

jQuery.ajax({ url: ' http://localhost/example', data: {

myValue1: 'foo', myValue1: 'bar'

}, success: function(data, textStatus) {

this.data == null BUG IS HERE this.success == function() as expected

} )


USING A POST:

jQuery.ajax({ url: ' http://localhost/example', type: 'POST' data: {

myValue1: 'foo', myValue1: 'bar'

}, success: function(data, textStatus) {

this.data == 'myValue1=foo&myValue2=bar'; this.success == function() as expected

} )

My perspective is that if 'data' as passed in options to jQuery.ajax is N/V pairs, as is the case with this example, the 'data' property on the call back context should be that very same object, regardless as to GET or POST, also not URL encoded etc.

Would be very convenient and helpful if it worked as such.

Change History

comment:1 Changed 3 years ago by rtaylor

Also, doc thusly reads incorrectly:

 http://docs.jquery.com/Ajax/jQuery.ajax.......

function (data, textStatus) {

data could be xmlDoc, jsonObj, html, text, etc... this; the options for this ajax request

}

comment:2 Changed 20 months ago by dmethvin

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

This was fixed in 1.4.

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.