Advertisement
Guest User

Untitled

a guest
Aug 31st, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. var $ = require('jquery'),
  2. XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
  3.  
  4. $.support.cors = true;
  5. $.ajaxSettings.xhr = function() {
  6. return new XMLHttpRequest();
  7. };
  8.  
  9. var najax = require('najax');
  10. najax('http://www.google.com', function(html){ console.log(html); });
  11. najax('http://www.google.com', { type:'POST' }, function(html){ console.log(html); });
  12. najax({ url:'http://www.google.com', type:'POST', success: function(html){ console.log(html); });
  13. najax({ url:'http://www.google.com', type:'POST' }).success(function(resp){}).error(function(err){});
  14.  
  15. najax.get, najax.post, najax.put, najax.delete...
  16.  
  17. if (typeof window === 'undefined') { // Running in NodeJS
  18. var domino=require('domino');
  19. var $=require('jquery')(domino.createWindow());
  20. var XMLHttpRequest=require('xmlhttprequest').XMLHttpRequest;
  21. $.support.cors=true; // cross domain
  22. $.ajaxSettings.xhr=function(){return new XMLHttpRequest();};
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement