#11967 closed bug (invalid)
data argument in ajax dataFilter callback is undefined
Reported by: | Owned by: | ||
---|---|---|---|
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.
Change History (7)
comment:1 Changed 10 years ago by
Component: | unfiled → ajax |
---|---|
Owner: | set to [email protected]… |
Priority: | undecided → low |
Status: | new → pending |
comment:2 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
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 10 years ago by
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 10 years ago by
jsFiddle handles CoffeeScript? Please provide a JavaScript version.
comment:5 Changed 10 years ago by
comment:6 Changed 10 years ago by
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 10 years ago by
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.
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.