REMINDER
Ability to modify documentation defaults
-
Hello team,
I'd love to know if it were possible to edit the default structure/code samples in the documentation, or the way they are generated.
For example, for a request like this:
var settings = { "url": "https://my.server/api/endpoint", "data": { "token" : "abcde", "videoID" : "o2in43ntek", "uniqueUsersOnly" : "0", "company" : "2" }, "method": "POST", "async": true, "crossDomain": true, "processData": true }; $.ajax(settings).done(function (response) { console.log(response); // TODO: Do something with the result });
I would like to add:
json: true
To the list of parameters so that the response is automatically treated / parsed as JSON.
It's a small example
-
Hm, do you mean add
JSON.parse(response)
to the result object? -
Whoops, sorry. I meant
dataType: "json"
Yes, you could add "response = JSON.parse(response)", for example. But, if you add "json" : "true" to the parameters, jQuery's ajax function will automatically parse it for you
From jQuery's docs:
https://api.jquery.com/jquery.ajax (search 'dataType')I'd also prefer to add default error handling logic, for example... so, adding a
.catch(function (error) { myErrorReportingFunction(error); }
That, for example, would be very, very helpful.