Skip to main content

Bug Tracker

Side navigation

#11967 closed bug (invalid)

Opened June 25, 2012 08:32AM UTC

Closed July 10, 2012 08:29AM UTC

Last modified October 12, 2012 01:08AM UTC

data argument in ajax dataFilter callback is undefined

Reported by: martijn@thany.nl Owned by: martijn@thany.nl
Priority: low Milestone: None
Component: ajax Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

This is the code I'm executing:

$.ajax({
  cache: false,
  dataType: "jsonp",
  dataFilter: function(data, type) {
    console.log(data);
    var results = (data || { }).results || "";
    return $.parseJSON(results);
  },
  data: { q: "select * from json where url='http://cdn.api.twitter.com/1/urls/count.json?url=http://www.google.nl/'" },
  url: "http://query.yahooapis.com/v1/public/yql",
});

On the console it prints ''undefined'', because the data argument in the dataFilter callback is undefined. I can't see why that would be the case, since the request returns a completely valid (and non-empty) JSON response, therefor the reason for filing it as a bug.

The fact that I'm getting the actual JSON from YQL as a JSON-encoded string, is another problem, but that's the reason I'm trying dataFilter to solve it.

Browser used: Firefox 13.0.1, Firebud 1.9.2.

Attachments (0)
Change History (7)

Changed June 25, 2012 11:42AM UTC by addyosmani comment:1

component: unfiledajax
owner: → martijn@thany.nl
priority: undecidedlow
status: newpending

Thanks for submitting a ticket to the jQuery bug tracker. Could you kindly post the above snippet as a complete test case on jsfiddle.net so we can verity what you're seeing?. Also please be sure to check against jQuery-git/1.8beta to make sure this issue hasn't already been addressed.

Changed July 10, 2012 08:29AM UTC by trac-o-bot comment:2

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 October 11, 2012 10:27PM UTC by lele@youleaf.com comment:3

I have the same problem: data argument in the dataFilter callback is undefined

I'm attaching a jsfiddle example.

http://jsfiddle.net/MPK4n/1/

Changed October 11, 2012 10:35PM UTC by dmethvin comment:4

jsFiddle handles CoffeeScript? Please provide a JavaScript version.

Changed October 12, 2012 12:18AM UTC by lele@youleaf.com comment:5

Sorry, my fault.

Here you can find a js version.

http://jsfiddle.net/MPK4n/3/

Changed October 12, 2012 12:34AM UTC by dmethvin comment:6

The docs say:

dataFilter: A function to be used to handle the raw response data of XMLHttpRequest

A JSONP request is not an XHR request so there is no XHR object and no raw data.

Changed October 12, 2012 01:08AM UTC by lele@youleaf.com comment:7

Thanks.

"Some types of Ajax requests, such as JSONP and cross-domain GET requests, do not use XHR; in those cases the XMLHttpRequest and textStatus parameters passed to the callback are undefined."

My bad, I've missed that in http://api.jquery.com/jQuery.ajax.

I guess the ticket can be closed.