From 73391c9e4205af7fb1571c12961f3ab9b1e8fa54 Mon Sep 17 00:00:00 2001 From: ninadsp Date: Tue, 31 Aug 2010 19:54:07 +0530 Subject: [PATCH] Append a random number for all Ajax queries on these pages to prevent server side caching from affecting the results --- js/db_search.js | 10 ++++++++++ js/server_privileges.js | 16 ++++++++++++++-- js/sql.js | 9 +++++++++ js/tbl_select.js | 10 ++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/js/db_search.js b/js/db_search.js index 8a0474ff2..94fdf6cf0 100644 --- a/js/db_search.js +++ b/js/db_search.js @@ -15,6 +15,16 @@ $(document).ready(function() { + /** + * Set a parameter for all Ajax queries made on this page. Append a random + * number to tell server that each Ajax request is a new one + */ + $.ajaxSetup({ + data: {'random': function() { + return Math.random(); + }} + }); + /** * Ajax Event handler for retrieving the result of an SQL Query * diff --git a/js/server_privileges.js b/js/server_privileges.js index e59ec6297..dff2c65ba 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -159,7 +159,19 @@ function appendNewUser(new_user_string, new_user_initial, new_user_initial_strin $(document).ready(function() { /** @lends jQuery */ - + + /** + * Set a parameter for all Ajax queries made on this page. Some queries + * are affected by cache settings on the server side, and hence, show stale + * data. Append a random number to tell server that each Ajax request is a + * new one + */ + $.ajaxSetup({ + data: {'random': function() { + return Math.random(); + }} + }); + /** * AJAX event handler for 'Add a New User' * @@ -445,7 +457,7 @@ $(document).ready(function() { PMA_ajaxShowMessage(); - $.get($(this).attr('href'), {'ajax_request' : true, 'random': Math.random()}, function(data) { + $.get($(this).attr('href'), {'ajax_request' : true}, function(data) { $("#usersForm") .hide("medium") .siblings("#initials_table") diff --git a/js/sql.js b/js/sql.js index a2000ac24..76e6c4056 100644 --- a/js/sql.js +++ b/js/sql.js @@ -107,6 +107,15 @@ function appendInlineAnchor(disp_mode) { */ $(document).ready(function() { + /** + * Set a parameter for all Ajax queries made on this page. Append a random + * number to tell server that each Ajax request is a new one + */ + $.ajaxSetup({ + data: {'random': function() { + return Math.random(); + }} + }); /** * current value of the direction in which the table is displayed diff --git a/js/tbl_select.js b/js/tbl_select.js index 88796bcfc..12072b049 100644 --- a/js/tbl_select.js +++ b/js/tbl_select.js @@ -13,6 +13,16 @@ */ $(document).ready(function() { + /** + * Set a parameter for all Ajax queries made on this page. Append a random + * number to tell server that each Ajax request is a new one + */ + $.ajaxSetup({ + data: {'random': function() { + return Math.random(); + }} + }); + /** * Ajax event handler for Table Search *