How to generate data in $.ajax success so it can be passed to Deferred .done() ?
Hypothetical situation:
I want to poll 5 newssites, where each news sites returns a differently builded JSON-response.
I use 1 object per website.
So for example, in CNN.js I have a method
grabNews which is a $.ajax() request.
In its success method, I check the JSON response ( data ) and I want to grab only the information that I'm interested in ( # of articles from today ).
I have the same method in my CNBC.js
In another more generic JS file, I have an object named objNewssite which can contain either my CNN or my CNBC object.
Here I want to do the following:
- objNewssite.grabNews().done(
- function(.....){
- console.log(numberOfArticlesFromToday);
- }
- );
How should I do this?
How do I process custom data in success to make it more generic so I can later use the more generic version in my chaining of the deferreds ?