Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.options = {
- 'app_url': $(document).find('[name="APP_URL"]').attr('content'),
- 'api': $(document).find('[name="APP_URL"]').attr('content') + '/api/plano-contas',
- 'token': $(document).find('[name="_token"]').attr('content')
- };
- /**
- *
- */
- this.callSS = function (data, callback) {
- var call = {
- url: this.options.api,
- data: data,
- dataType: "json",
- type: "GET",
- success: function (data) {
- if(typeof callback === 'function') {
- callback(data);
- } else {
- console.log('----------> success');
- console.log(data);
- console.log('');
- }
- },
- error: function (xhr, ajaxOptions, thrownError) {
- console.error('----------> error');
- console.error(xhr);
- console.error(ajaxOptions);
- console.error(thrownError);
- console.log('');
- }
- };
- if(typeof callback == 'object') {
- call = $.extend({}, call, callback);
- }
- call.data._token = this.options.token;
- $.ajax(call);
- };
- /**
- *
- */
- this.url = function(str) {
- this.options.app_url + str;
- };
- // data e success
- this.callSS({}, function() {
- alert("hue");
- });
- // data forma completa
- this.callSS({}, {
- 'success': function() {
- },
- 'error': function() {
- }
- });
- // data forma completa
- this.callSS({}, {
- 'url': this.url('/asdfasdfasdfasdfasdfasdf'),
- 'success': function() {
- },
- 'error': function() {
- }
- });
- // data forma completa
- this.callSS({}, {
- 'url': 'http://www.google.com',
- 'success': function() {
- },
- 'error': function() {
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement