diff --git a/js/db_operations.js b/js/db_operations.js index 5169b553c..b0536942c 100644 --- a/js/db_operations.js +++ b/js/db_operations.js @@ -34,10 +34,7 @@ $(document).ready(function() { var question = 'CREATE DATABASE ' + $('#new_db_name').val() + ' / DROP DATABASE ' + window.parent.db; - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } - + PMA_prepareForAjaxRequest($form); /** * @var button_options Object containing options for jQueryUI dialog buttons */ @@ -95,9 +92,7 @@ $(document).ready(function() { var $form = $(this); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); $.get($form.attr('action'), $form.serialize(), function(data) { // use messages that stay on screen @@ -135,9 +130,7 @@ $(document).ready(function() { var $form = $(this); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); PMA_ajaxShowMessage(PMA_messages['strChangingCharset']); diff --git a/js/db_search.js b/js/db_search.js index 73bea25fb..79c444e85 100644 --- a/js/db_search.js +++ b/js/db_search.js @@ -142,10 +142,7 @@ $(document).ready(function() { // jQuery object to reuse $form = $(this); - // add this hidden field just once - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); $.post($form.attr('action'), $form.serialize() + "&submit_search=" + $("#buttonGo").val(), function(response) { if (typeof response == 'string') { diff --git a/js/functions.js b/js/functions.js index 1016b2f81..6894e15a4 100644 --- a/js/functions.js +++ b/js/functions.js @@ -20,6 +20,18 @@ var only_once_elements = new Array(); */ var ajax_message_init = false; +/** + * Add a hidden field to the form to indicate that this will be an + * Ajax request (only if this hidden field does not exist) + * + * @param object the form + */ +function PMA_prepareForAjaxRequest($form) { + if (! $form.find('input:hidden').is('#ajax_request_hidden')) { + $form.append(''); + } +} + /** * Generate a new password and copy it to the password input areas * @@ -1403,9 +1415,7 @@ $(document).ready(function() { button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();} var $msgbox = PMA_ajaxShowMessage(); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); $.get($form.attr('action'), $form.serialize(), function(data) { //in the case of an error, show the error message returned. @@ -1467,9 +1477,7 @@ $(document).ready(function() { // OK, form passed validation step if ($form.hasClass('ajax')) { PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); //User wants to submit the form $.post($form.attr('action'), $form.serialize() + "&do_save_data=" + $(this).val(), function(data) { if(data.success == true) { @@ -1561,9 +1569,7 @@ $(document).ready(function() { var $form = $("#create_table_form"); var $msgbox = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); //User wants to add more fields to the table $.post($form.attr('action'), $form.serialize() + "&submit_num_fields=" + $(this).val(), function(data) { @@ -1670,10 +1676,7 @@ $(document).ready(function() { $form = $(this); PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); $.post($form.attr('action'), $form.serialize(), function(data) { if(data.success == true) { diff --git a/js/sql.js b/js/sql.js index 8a97eec3a..77717a727 100644 --- a/js/sql.js +++ b/js/sql.js @@ -254,9 +254,7 @@ $(document).ready(function() { $form = $(this); var $msgbox = PMA_ajaxShowMessage(); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); $.post($(this).attr('action'), $(this).serialize() , function(data) { if(data.success == true) { diff --git a/js/tbl_change.js b/js/tbl_change.js index e5b800fa0..2d33884a9 100644 --- a/js/tbl_change.js +++ b/js/tbl_change.js @@ -283,9 +283,7 @@ $(document).ready(function() { event.preventDefault(); PMA_ajaxShowMessage(); - if (! $form.find('input:hidden').is('#ajax_request_hidden')) { - $form.append(''); - } + PMA_prepareForAjaxRequest($form); $.post($form.attr('action'), $form.serialize(), function(data) { if (typeof data.success != 'undefined') { diff --git a/js/tbl_select.js b/js/tbl_select.js index 88acefff5..8115245cb 100644 --- a/js/tbl_select.js +++ b/js/tbl_select.js @@ -60,10 +60,7 @@ $(document).ready(function() { $("#sqlqueryresults").empty(); var msgbox = PMA_ajaxShowMessage(PMA_messages['strSearching']); - // add this hidden field just once - if (! $search_form.find('input:hidden').is('#ajax_request_hidden')) { - $search_form.append(''); - } + PMA_prepareForAjaxRequest($search_form); $.post($search_form.attr('action'), $search_form.serialize(), function(response) { if (typeof response == 'string') {