Bug Tracker

Modify

Ticket #11967 (closed bug: invalid)

Opened 12 months ago

Last modified 8 months ago

data argument in ajax dataFilter callback is undefined

Reported by: martijn@… Owned by: martijn@…
Priority: low Milestone: None
Component: ajax Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 12 months ago by addyosmani

  • Owner set to martijn@…
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to ajax

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 11 months ago by trac-o-bot

  • Status changed from pending to closed
  • Resolution set to invalid

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 8 months ago by lele@…

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 8 months ago by dmethvin

jsFiddle handles CoffeeScript? Please provide a JavaScript version.

comment:5 Changed 8 months ago by lele@…

Sorry, my fault.

Here you can find a js version.

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

comment:6 Changed 8 months 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 8 months ago by lele@…

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.

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.