Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fetch: function(successCallback, errorCallback) {
- var apiUrl = this.applyFilter(filters);
- var self = this;
- this.log('fetch', apiUrl, currentSearchMode);
- $.ajax({
- url: apiUrl,
- type: 'GET',
- cache: (debug) ? true: false,
- processData: true,
- crossDomain: true,
- scriptCharset: 'UTF-8',
- jsonp: 'callback',
- dataType: 'jsonp',
- success: function(data, statusText, jqXHR) {
- console.log(jqXHR);
- // if(jqXHR.status == 400){
- // console.log('there is an error');
- // }
- self.log('fetch::success', data);
- if (typeof data.error !== 'undefined') {
- showNoResultError = true;
- var appData = lastValidResult[currentSearchMode];
- } else {
- showNoResultError = false;
- var appData = self.normalize[currentSearchMode](self, data);
- lastValidResult[currentSearchMode] = appData;
- }
- if (typeof successCallback === 'function')
- successCallback(appData);
- },
- error: function(jqXHR, textStatus, errorThrown) {
- //do sth here
- // if(jqXHR.status&&jqXHR.status==400){
- // alert(jqXHR.responseText);
- // }else{
- // alert("Something went wrong");
- // }
- // console.log('works now');
- // self.log('fetch::error', textStatus, errorThrown);
- // if (typeof errorCallback === 'function')
- // errorCallback.apply(this, arguments);
- },
- complete: function(jqXHR, textStatus) {
- console.log(jqXHR);
- console.log('complete');
- }
- });
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement