diff --git a/js/sql.js b/js/sql.js index 82fcef4294..c6f2f0cd32 100644 --- a/js/sql.js +++ b/js/sql.js @@ -172,13 +172,28 @@ $(document).ready(function() { $.post($form.attr('action'), $form.serialize() , function(data) { if (data.success == true) { + // success happens if the query returns rows or not + // // fade out previous messages, if any $('.success').fadeOut(); $('.sqlquery_message').fadeOut(); // show a message that stays on screen - if (typeof data.sql_query != 'undefined') { - $('#sqlquery').html(data.sql_query); - setQuery(data.sql_query); + if (typeof data.action_bookmark != 'undefined') { + // view only + if ('1' == data.action_bookmark) { + $('#sqlquery').text(data.sql_query); + // send to codemirror if possible + setQuery(data.sql_query); + } + // delete + if ('2' == data.action_bookmark) { + $("#id_bookmark option[value='" + data.id_bookmark + "']").remove(); + } + $('#sqlqueryform').before(data.message); + } elseif (typeof data.sql_query != 'undefined') { + $('
') + .html(data.sql_query) + .insertBefore('#sqlqueryform'); // unnecessary div that came from data.sql_query $('.notice').remove(); } else { @@ -197,11 +212,6 @@ $(document).ready(function() { $('body').html(data); }); // end inner post } - if (typeof data.action_bookmark != 'undefined') { - if ('2' == data.action_bookmark) { - $("#id_bookmark option[value='" + data.id_bookmark + "']").remove(); - } - } } else if (data.success == false ) { // show an error message that stays on screen $('#sqlqueryform').before(data.error);