Edward,
On 7/10/14, Edward Cheng c4150221@gmail.com wrote:
Hi,
Till now, new console will log browse-generated-queries, but only happend at global AJAX handler, because I add some code in global AJAX handler:
if(PMA_console && PMA_console.isEnabled) { PMA_console.ajaxCallback(data); }
We can copy code above to everywhere--to every custom ajax response handler--it's terrible, do we have a better solution?
I think we can pin point certain actions that the user does for which we need to append SQL to console and then manually add your 'if' block in those custom handlers. I think it could be done just for structure, search, insert, privileges, operations pages. Or are we appending to console on every click and every form submit? Then, it'll be a lot of places :)
To automate, we could use .ajaxSuccess or .ajaxComplete events for $(".ajax") selectors that have custom callbacks, but I wonder if this is a good solution. An example using links [0][1]
$( document ).ajaxSuccess( function( event, xhr, settings ) { if ( settings.url == "import.php" || settings.url == "tbl_select.php" || ....other selective urls ) { // maybe more checks on 'event' to ascertain that this is the relevant ajax request // and then var data = jQuery.parseJSON(xhr.responseText); if(PMA_console && PMA_console.isEnabled) { PMA_console.ajaxCallback(data); } } });
Or maybe we could use $.ajaxPrefilter, see [2] and [3]..
[0] http://api.jquery.com/ajaxSuccess/ [1] http://api.jquery.com/ajaxComplete/ [2] http://api.jquery.com/jquery.ajaxprefilter/ [3] http://stackoverflow.com/questions/5489070/use-jquery-ajax-prefilter-to-insp...