Skip to main content

Bug Tracker

Side navigation

#4851 closed bug (fixed)

Opened July 04, 2009 06:52PM UTC

Closed June 11, 2010 03:09AM UTC

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

Attachments (0)
Change History (2)

Changed July 04, 2009 06:59PM UTC by rtaylor comment:1

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

}

Changed June 11, 2010 03:09AM UTC by dmethvin comment:2

resolution: → fixed
status: newclosed

This was fixed in 1.4.