[Phpmyadmin-devel] [Console] Help, about AJAX callback

Edward Cheng c4150221 at gmail.com
Sun Jul 13 18:11:16 CEST 2014


2014-07-13 23:50 GMT+08:00 Atul Pratap Singh <atulpratapsingh05 at gmail.com>:
> Edward,
>
> On 7/10/14, Edward Cheng <c4150221 at 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 :)
Umm... Console contains history, it best looks same as you click the
history button, and there's an option under Options tab for you to
disable log them.
>
> 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]
Yes, Absolutely a good solution! I don't know this API before you told
me, thanks, really :)
>
> $( 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-inspect-response-data-and-conditionally-forward-to
>
> --
> Regards
>
> Atul Pratap Singh
> http://blog.atulsisodia.in/
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Phpmyadmin-devel mailing list
> Phpmyadmin-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel



-- 
Edward Cheng




More information about the Developers mailing list