HosipLan

Untitled

Mar 12th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var AjaxRequest = function (url) {
  2.     this.opts = {
  3.         'url': url,
  4.         'method': 'GET',
  5.         'data': {},
  6.         'dataType': 'json',
  7.         'headers': {},
  8.         'cache': true,
  9.         'crossDomain': true,
  10.         'success': function () {},
  11.         'error': function (jqXHR, textStatus, errorThrown) {
  12.             console.log(jqXHR, textStatus, errorThrown);
  13.         },
  14.         'complete': function () {},
  15.         'beforeSend': function () {}
  16.         };
  17. }
  18.  
  19. AjaxRequest.prototype.setOption = function(name, value) {
  20.     this.opts[name] = value;
  21.     return this;
  22. }
  23.  
  24. AjaxRequest.prototype.send = function () {
  25.     jQuery.support.cors = true
  26.     return $.ajax(this.opts);
  27. };
  28.  
  29.  
  30. var request = new AjaxRequest("http://");
  31. request.send();
Advertisement
Add Comment
Please, Sign In to add comment