Skip to content

Commit

Permalink
Move jquery config near to jquery require
Browse files Browse the repository at this point in the history
  • Loading branch information
cristoper committed Jan 10, 2016
1 parent 9ce6f82 commit 89e8460
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fetchkivajson.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* $ node fetchkivajson.js > partners.json
*
* It does this by loading the jquery-kivasort plugin, and executing the same
* function that plugin uses in the browser. jQuery and jsdom are required.
* function that plugin uses in the browser. jquery and jsdom are required.
*/

var fs = require("fs");
Expand All @@ -18,6 +18,12 @@ document = require('jsdom').jsdom(undefined);
window = document.defaultView;
jQuery = require('jquery');

// configure jQuery ajax
jQuery.support.cors = true;
jQuery.ajaxSettings.xhr = function() {
return new XMLHttpRequest();
};

/** dummy object so we don't have to require datatables
* from node.js
*/
Expand All @@ -26,12 +32,6 @@ jQuery.fn= {dataTable: {ext: {}}};
// load jquery-kivasort plugin
var plugin = require('./kiva_sort.js');

// configure jQuery ajax
jQuery.support.cors = true;
jQuery.ajaxSettings.xhr = function() {
return new XMLHttpRequest();
};

// Fetch data and send it to stdout
plugin.fetchKivaPartners().done(function(data) {
console.log({partners: data});
Expand Down

0 comments on commit 89e8460

Please sign in to comment.