mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-05-02 06:26:16 -04:00
switching to full JSON API without POST array use, ensure all JSON operations are done with error detection
This commit is contained in:
parent
be1e7babc0
commit
cc1c55129f
14 changed files with 187 additions and 103 deletions
|
@ -3712,27 +3712,22 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
{
|
||||
let isPost = Object.keys(data).length > 0,
|
||||
ajaxParams = {
|
||||
type: isPost ? 'POST' : 'GET',
|
||||
url: url,
|
||||
headers: ajaxHeaders,
|
||||
success: function(result) {
|
||||
if (result.status === 0) {
|
||||
success(0, result);
|
||||
} else if (result.status === 1) {
|
||||
fail(1, result);
|
||||
} else {
|
||||
fail(2, result);
|
||||
type: isPost ? 'POST' : 'GET',
|
||||
url: url,
|
||||
headers: ajaxHeaders,
|
||||
dataType: 'json',
|
||||
success: function(result) {
|
||||
if (result.status === 0) {
|
||||
success(0, result);
|
||||
} else if (result.status === 1) {
|
||||
fail(1, result);
|
||||
} else {
|
||||
fail(2, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
if (isPost) {
|
||||
ajaxParams.data = data;
|
||||
['adata', 'meta'].map(function (key) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
ajaxParams.data[key] = JSON.stringify(data[key]);
|
||||
}
|
||||
});
|
||||
ajaxParams.dataType = 'json';
|
||||
ajaxParams.data = JSON.stringify(data);
|
||||
}
|
||||
$.ajax(ajaxParams).fail(function(jqXHR, textStatus, errorThrown) {
|
||||
console.error(textStatus, errorThrown);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue