Skip to content

Commit

Permalink
Update json response css.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed Feb 12, 2016
2 parents 1b12909 + b33716d commit d6bea2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ More examples and best practice hints: [EXAMPLES.md](https://github.com/apidoc/a

* [flask-apidoc](https://pypi.python.org/pypi/flask-apidoc/) `pip install flask-apidoc`
* [grunt-apidoc](https://github.com/apidoc/grunt-apidoc) `npm install grunt-apidoc`.
* [gapidoc (gulp)](https://github.com/techgaun/gulp-apidoc) `npm install gapidoc`.
* [gulp-apidoc](https://github.com/ayhankuru/gulp-apidoc) `npm install gulp-apidoc`.
* [gulp-apidocjs](https://github.com/apriendeau/gulp-apidocjs) `npm install gulp-apidocjs`.


## Editor integration
Expand Down
27 changes: 2 additions & 25 deletions template/utils/send_sample_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,38 +77,15 @@ define([
// send AJAX request, catch success or error callback
var ajaxRequest = {
url : url,
dataType : "json",
contentType: "application/json",
headers : header,
data : param,
type : type.toUpperCase(),
success : displaySuccess,
error : displayError
};

if (type === 'get') {
ajaxRequest.url = url + paramToQueryParms(param),
ajaxRequest.dataType = "text";
ajaxRequest.contentType = "text/plain";
} else {
if ( ! $.isEmptyObject(param)) {
ajaxRequest.data = JSON.stringify(param);
}
}
$.ajax(ajaxRequest);

function paramToQueryParms(param) {
var p = 0;
var queryParms = "";
for (var k in param) {
if (p === 0) {
queryParms += "?" + k + "=" + param[k];
} else {
queryParms += "&" + k + "=" + param[k];
}
p++;
}
return queryParms;
}

function displaySuccess(data, status, jqXHR) {
var jsonResponse;
Expand All @@ -130,7 +107,7 @@ define([
jsonResponse = JSON.parse(jqXHR.responseText);
jsonResponse = JSON.stringify(jsonResponse, null, 4);
} catch (e) {
jsonResponse = jqXHR.responseText;
jsonResponse = escape(jqXHR.responseText);
}

if (jsonResponse)
Expand Down

0 comments on commit d6bea2a

Please sign in to comment.