mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Add support for passing URL to Rhymix.ajax()
This commit is contained in:
parent
bb86fc2fe2
commit
87980cd35c
1 changed files with 24 additions and 18 deletions
|
|
@ -429,8 +429,18 @@ Rhymix.ajax = function(action, params, callback_success, callback_error) {
|
||||||
|
|
||||||
// Extract module and act
|
// Extract module and act
|
||||||
let isFormData = params instanceof FormData;
|
let isFormData = params instanceof FormData;
|
||||||
let module, act;
|
let module, act, url;
|
||||||
if (!action) {
|
if (action) {
|
||||||
|
if (typeof action === 'string' && action.match(/^[a-z0-9_]+\.[a-z0-9_]+$/i)) {
|
||||||
|
let parts = action.split('.');
|
||||||
|
params = params || {};
|
||||||
|
params.module = module = parts[0];
|
||||||
|
params.act = act = parts[1];
|
||||||
|
} else {
|
||||||
|
url = action;
|
||||||
|
action = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (isFormData) {
|
if (isFormData) {
|
||||||
module = params.get('module');
|
module = params.get('module');
|
||||||
act = params.get('act');
|
act = params.get('act');
|
||||||
|
|
@ -444,26 +454,22 @@ Rhymix.ajax = function(action, params, callback_success, callback_error) {
|
||||||
} else {
|
} else {
|
||||||
action = null;
|
action = null;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
action = action.split('.');
|
|
||||||
params = params || {};
|
|
||||||
params.module = module = action[0];
|
|
||||||
params.act = act = action[1];
|
|
||||||
action = action.join('.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add action to URL if the current rewrite level supports it
|
// Add action to URL if the current rewrite level supports it
|
||||||
let url = this.URI(window.request_uri).pathname() + 'index.php';
|
if (!url) {
|
||||||
if (act) {
|
url = this.URI(window.request_uri).pathname() + 'index.php';
|
||||||
url = url + '?act=' + act;
|
if (act) {
|
||||||
|
url = url + '?act=' + act;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (this.getRewriteLevel() >= 2 && action !== null) {
|
||||||
|
url = url + '_' + action.replace('.', '/');
|
||||||
|
} else {
|
||||||
|
url = url + 'index.php';
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (this.getRewriteLevel() >= 2 && action !== null) {
|
|
||||||
url = url + action.replace('.', '/');
|
|
||||||
} else {
|
|
||||||
url = url + 'index.php';
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Add a CSRF token to the header, and remove it from the parameters
|
// Add a CSRF token to the header, and remove it from the parameters
|
||||||
const headers = {
|
const headers = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue