Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#11967 closed bug (invalid)

data argument in ajax dataFilter callback is undefined

Reported by: [email protected] Owned by: [email protected]
Priority: low Milestone: None
Component: ajax Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


This is the code I'm executing:

  cache: false,
  dataType: "jsonp",
  dataFilter: function(data, type) {
    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.

Change History (7)

comment:1 Changed 9 years ago by addyosmani

Component: unfiledajax
Owner: set to [email protected]
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.

comment:2 Changed 9 years ago by trac-o-bot

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!

comment:3 Changed 9 years ago by [email protected]

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

I'm attaching a jsfiddle example. http://jsfiddle.net/MPK4n/1/

comment:4 Changed 9 years ago by dmethvin

jsFiddle handles CoffeeScript? Please provide a JavaScript version.

comment:5 Changed 9 years ago by [email protected]

Sorry, my fault.

Here you can find a js version.


comment:6 Changed 9 years ago by dmethvin

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.

comment:7 Changed 9 years ago by [email protected]


"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.

Note: See TracTickets for help on using tickets.