Ticket #8267 (closed bug: worksforme)
$.ajax, dataFilter broken
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | ajax | Version: | 1.5 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
jQuery ajax success method no longer receives any data when using the dataFilter method and returning sanitized data.
Change History
comment:1 Changed 2 years ago by jitter
- Priority changed from undecided to low
- Resolution set to worksforme
- Status changed from new to closed
- Component changed from unfiled to ajax
comment:2 Changed 2 years ago by vmx
I ran into the same issue, although it isn't a bug, it's not very clear either.
When the dataType is 'json' and your dataFilter returns JSON you will get 'null' back to your success function. When you return a string, it will be parsed and passed on to the success function.
So when you want to have the result of the dataFilter function passed on as is, then you need to set the dataType to 'text'.
Here are examples on jsFiddle:
- JSON is returned: http://jsfiddle.net/DSeD2/
- 'null' is returned: http://jsfiddle.net/DSeD2/1/
- it's passed on as is (JSON): http://jsfiddle.net/DSeD2/2/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for taking the time to contribute to the jQuery project by writing a bug report.
As you didn't provide the test case (or any of the other data) requested in the bug reporting guidelines, I went ahead and made this test case which works for me.
Thus please report back with a reduced test case, that reproduces the issue you are experiencing, on http://jsfiddle.net. So that we can reopen this ticket and investigate the issue further.