Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. fetch: function(successCallback, errorCallback) {
  2. var apiUrl = this.applyFilter(filters);
  3. var self = this;
  4.  
  5. this.log('fetch', apiUrl, currentSearchMode);
  6.  
  7. $.ajax({
  8. url: apiUrl,
  9. type: 'GET',
  10. cache: (debug) ? true: false,
  11. processData: true,
  12. crossDomain: true,
  13. scriptCharset: 'UTF-8',
  14. jsonp: 'callback',
  15. dataType: 'jsonp',
  16. success: function(data, statusText, jqXHR) {
  17. console.log(jqXHR);
  18. // if(jqXHR.status == 400){
  19. // console.log('there is an error');
  20. // }
  21. self.log('fetch::success', data);
  22. if (typeof data.error !== 'undefined') {
  23. showNoResultError = true;
  24. var appData = lastValidResult[currentSearchMode];
  25. } else {
  26. showNoResultError = false;
  27. var appData = self.normalize[currentSearchMode](self, data);
  28. lastValidResult[currentSearchMode] = appData;
  29. }
  30. if (typeof successCallback === 'function')
  31. successCallback(appData);
  32. },
  33. error: function(jqXHR, textStatus, errorThrown) {
  34. //do sth here
  35.  
  36. // if(jqXHR.status&&jqXHR.status==400){
  37. // alert(jqXHR.responseText);
  38. // }else{
  39. // alert("Something went wrong");
  40. // }
  41. // console.log('works now');
  42. // self.log('fetch::error', textStatus, errorThrown);
  43. // if (typeof errorCallback === 'function')
  44. // errorCallback.apply(this, arguments);
  45. },
  46. complete: function(jqXHR, textStatus) {
  47. console.log(jqXHR);
  48. console.log('complete');
  49. }
  50. });
  51. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement