Show More
@@ -36,18 +36,22 b' var toQueryString = function(o) {' | |||||
36 | /** |
|
36 | /** | |
37 | * ajax call wrappers |
|
37 | * ajax call wrappers | |
38 | */ |
|
38 | */ | |
39 | var ajaxGET = function(url, success) { |
|
39 | var ajaxGET = function(url, success, failure) { | |
40 | var sUrl = url; |
|
40 | var sUrl = url; | |
41 | var request = $.ajax({url: sUrl, headers: {'X-PARTIAL-XHR': true}}) |
|
41 | var request = $.ajax({url: sUrl, headers: {'X-PARTIAL-XHR': true}}) | |
42 | .done(function(data){ |
|
42 | .done(function(data){ | |
43 | success(data); |
|
43 | success(data); | |
44 | }) |
|
44 | }) | |
45 | .fail(function(data, textStatus, xhr){ |
|
45 | .fail(function(data, textStatus, xhr) { | |
46 | alert("error processing request: " + textStatus); |
|
46 | if (failure) { | |
|
47 | failure(data, textStatus, xhr); | |||
|
48 | } else { | |||
|
49 | alert("error processing request: " + textStatus); | |||
|
50 | } | |||
47 | }); |
|
51 | }); | |
48 | return request; |
|
52 | return request; | |
49 | }; |
|
53 | }; | |
50 | var ajaxPOST = function(url,postData,success) { |
|
54 | var ajaxPOST = function(url, postData, success, failure) { | |
51 | var sUrl = url; |
|
55 | var sUrl = url; | |
52 | var postData = toQueryString(postData); |
|
56 | var postData = toQueryString(postData); | |
53 | var request = $.ajax({type: 'POST', data: postData, url: sUrl, |
|
57 | var request = $.ajax({type: 'POST', data: postData, url: sUrl, | |
@@ -56,7 +60,11 b' var ajaxPOST = function(url,postData,suc' | |||||
56 | success(data); |
|
60 | success(data); | |
57 | }) |
|
61 | }) | |
58 | .fail(function(data, textStatus, xhr){ |
|
62 | .fail(function(data, textStatus, xhr){ | |
59 | alert("error processing request: " + textStatus); |
|
63 | if (failure) { | |
|
64 | failure(data, textStatus, xhr); | |||
|
65 | } else { | |||
|
66 | alert("error processing request: " + textStatus); | |||
|
67 | } | |||
60 | }); |
|
68 | }); | |
61 | return request; |
|
69 | return request; | |
62 | }; |
|
70 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now