Share code for parsing data-post attribute
It can include leading question mark and we should deal with it in all locations. Fixes #13913 Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
d070e4a60f
commit
1fc566fd90
@ -283,15 +283,11 @@ var AJAX = {
|
||||
|
||||
var url = isLink ? href : $(this).attr('action');
|
||||
var params = 'ajax_request=true&ajax_page_request=true';
|
||||
var dataPost = AJAX.source.attr('data-post');
|
||||
var dataPost = AJAX.source.getPostData();
|
||||
if (! isLink) {
|
||||
params += '&' + $(this).serialize();
|
||||
} else if (dataPost) {
|
||||
// Strip possible leading ?
|
||||
if (dataPost.startsWith('?')) {
|
||||
dataPost = dataPost.substr(1);
|
||||
}
|
||||
params += '&' + AJAX.source.attr('data-post');
|
||||
params += '&' + dataPost;
|
||||
isLink = false;
|
||||
}
|
||||
if (! (history && history.pushState)) {
|
||||
|
||||
@ -298,7 +298,7 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
$this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function (url) {
|
||||
PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.attr('data-post'));
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.getPostData());
|
||||
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
@ -360,7 +360,7 @@ AJAX.registerOnload('db_structure.js', function () {
|
||||
$this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function (url) {
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.attr('data-post'));
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.getPostData());
|
||||
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
|
||||
@ -5086,3 +5086,16 @@ function configGet(key, cached=true)
|
||||
});
|
||||
return JSON.parse(localStorage.getItem(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return POST data as stored by Util::linkOrButton
|
||||
*/
|
||||
jQuery.fn.getPostData = function() {
|
||||
var dataPost = this.attr('data-post');
|
||||
// Strip possible leading ?
|
||||
if (dataPost.startsWith('?')) {
|
||||
dataPost = dataPost.substr(1);
|
||||
}
|
||||
return dataPost;
|
||||
};
|
||||
|
||||
|
||||
@ -401,7 +401,7 @@ RTE.COMMON = {
|
||||
* the AJAX message shown to the user
|
||||
*/
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
var params = getJSConfirmCommonParam(this, $this.attr('data-post'));
|
||||
var params = getJSConfirmCommonParam(this, $this.getPostData());
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success === true) {
|
||||
/**
|
||||
@ -476,7 +476,7 @@ RTE.COMMON = {
|
||||
* @var $curr_row Object containing reference to the current row
|
||||
*/
|
||||
var $curr_row = $anchor.parents('tr');
|
||||
var params = getJSConfirmCommonParam(this, $anchor.attr('data-post'));
|
||||
var params = getJSConfirmCommonParam(this, $anchor.getPostData());
|
||||
$.post($anchor.attr('href'), params, function (data) {
|
||||
returnCount++;
|
||||
if (data.success === true) {
|
||||
|
||||
@ -188,8 +188,9 @@ AJAX.registerOnload('sql.js', function () {
|
||||
$link.PMA_confirm(question, $link.attr('href'), function (url) {
|
||||
$msgbox = PMA_ajaxShowMessage();
|
||||
var params = 'ajax_request=1&is_js_confirmed=1';
|
||||
if ($link.attr('data-post')) {
|
||||
params += '&' + $link.attr('data-post');
|
||||
var postData = $link.getPostData();
|
||||
if (postData) {
|
||||
params += '&' + postData;
|
||||
}
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success) {
|
||||
|
||||
@ -183,7 +183,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
|
||||
var $this_anchor = $(this);
|
||||
$this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function (url) {
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strDroppingColumn, false);
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.attr('data-post'));
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.getPostData());
|
||||
params += '&ajax_page_request=1';
|
||||
$.post(url, params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
@ -269,7 +269,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
|
||||
PMA_ajaxShowMessage();
|
||||
AJAX.source = $this;
|
||||
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.attr('data-post'));
|
||||
var params = getJSConfirmCommonParam(this, $this_anchor.getPostData());
|
||||
params += '&ajax_page_request=1';
|
||||
$.post(url, params, AJAX.responseHandler);
|
||||
}); // end $.PMA_confirm()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user