Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Request() {
  2.     this.url = app.serviceUrl;
  3.    
  4.     this.send = function(method, type, params, callback) {
  5.        
  6.         console.log(method);
  7.         //console.log(type);
  8.         //console.log(params);
  9.        
  10.         localMethod = method.replace('/', '');
  11.        
  12.         if(dummy[localMethod] !== undefined) {
  13.             console.log('local');
  14.             callback(dummy[localMethod]);
  15.         } else {
  16.             console.log('online');
  17.             url = this.url+method;
  18.             console.log(url);
  19.             console.log('request sent: '+ url);
  20.             $.ajax({
  21.                 type: type,
  22.                 url: url,
  23.                 data: params,
  24.                 dataType: 'json'
  25.             })
  26.             .done(function(data) {
  27.                 if(callback) callback(data);
  28.             });
  29.         }
  30.     };
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement