mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 17:14:36 +01:00
sending appliction/json aka JSON as direct payload for all POST ajax requests
instead of additionally encoding them as form-data
This commit is contained in:
parent
be3bcab3e8
commit
bbe551d4cc
@ -108,14 +108,14 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
this.async = async;
|
this.async = async;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof method === 'undefined') method = 'POST';
|
||||||
|
|
||||||
// Assemble the complete request
|
// Assemble the complete request
|
||||||
var request_obj = {
|
var request_obj = JSON.stringify({
|
||||||
'json_data': this.egw.jsonEncode({
|
request: {
|
||||||
'request': {
|
parameters: this.parameters
|
||||||
'parameters': this.parameters
|
}
|
||||||
}
|
});
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send the request via AJAX using the jquery ajax function
|
// Send the request via AJAX using the jquery ajax function
|
||||||
// we need to use jQuery of window of egw object, as otherwise the one from main window is used!
|
// we need to use jQuery of window of egw object, as otherwise the one from main window is used!
|
||||||
@ -124,9 +124,11 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
url: this.url,
|
url: this.url,
|
||||||
async: this.async,
|
async: this.async,
|
||||||
context: this,
|
context: this,
|
||||||
data: request_obj,
|
// only POST can send JSON as direct payload, GET can not
|
||||||
|
data: method === 'GET' ? { json_data: request_obj } : request_obj,
|
||||||
|
contentType: method === 'GET' ? false : 'application/json',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: method || 'POST',
|
type: method,
|
||||||
success: this.handleResponse,
|
success: this.handleResponse,
|
||||||
error: error || this.handleError
|
error: error || this.handleError
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user