app/assets/javascripts/api_taster/app.js in api_taster-0.7.0 vs app/assets/javascripts/api_taster/app.js in api_taster-0.8.1
- old
+ new
@@ -16,15 +16,15 @@
$("fieldset[ref=url-params] input").prop("disabled", false);
},
detectContentType: function(response) {
var contentType = response.getResponseHeader("Content-Type");
- var detectedContentType = null
+ var detectedContentType = null;
if (contentType.match(/application\/json/)) {
detectedContentType = 'json';
- }
+ };
return detectedContentType;
},
fillInInfoTab: function($tab, xhr) {
@@ -53,12 +53,18 @@
}
}
}
return baseUrl;
- }
+ },
+ setHeaders: function(headers) {
+ this.headers = headers;
+ },
+
+ headers: []
+
};
$.fn.extend({
enableNavTabsFor: function(contentElement) {
@@ -115,9 +121,15 @@
$form = $(e.target);
ApiTaster.disableSubmitButton();
ApiTaster.disableUrlParams();
window.ajax = $.ajax({
+ beforeSend: function(xhr) {
+ var headers = ApiTaster.headers;
+ for(var l = headers.length, i = 0; i < l; i ++) {
+ xhr.setRequestHeader(headers[i].key, headers[i].value);
+ }
+ },
url: ApiTaster.getSubmitUrl($form),
type: $form.attr('method'),
data: $form.serialize()
}).complete(onComplete);