diff --git a/db_search.php b/db_search.php
index acfec8e55b..793fe91e88 100644
--- a/db_search.php
+++ b/db_search.php
@@ -40,11 +40,12 @@ $db_search = new PMA_DbSearch($GLOBALS['db']);
if ( $GLOBALS['is_ajax_request'] != true) {
include 'libraries/db_info.inc.php';
}
-$response->addHTML('
');
// Main search form has been submitted, get results
if (isset($_REQUEST['submit_search'])) {
$response->addHTML($db_search->getSearchResults());
+} else {
+ $response->addHTML('
');
}
// If we are in an Ajax request, we need to exit after displaying all the HTML
@@ -53,5 +54,9 @@ if ($GLOBALS['is_ajax_request'] == true && empty($_REQUEST['ajax_page_request'])
}
// Display the search form
+$response->addHTML('
'
+ . '
');
$response->addHTML($db_search->getSelectionForm($url_params));
+$response->addHTML($db_search->_getResultDivs());
?>
diff --git a/js/db_search.js b/js/db_search.js
index 6518aa062b..82fcec2ec1 100644
--- a/js/db_search.js
+++ b/js/db_search.js
@@ -44,15 +44,21 @@ function loadResult(result_path, table_name, link)
/** Load the browse results to the page */
$("#table-info").show();
$('#table-link').attr({"href" : 'sql.php?' + link }).text(table_name);
- var url = result_path + " #sqlqueryresults";
- $('#browse-results').load(url, null, function () {
- $('html, body')
- .animate({
- scrollTop: $("#browse-results").offset().top
- }, 1000);
- PMA_ajaxRemoveMessage($msg);
- PMA_makegrid($('#table_results')[0], true, true, true, true);
- }).show();
+ var url = result_path + "#sqlqueryresults";
+ $.get(url, {'ajax_request': true, 'is_js_confirmed': true}, function (data) {
+ if (data.success) {
+ $('#browse-results').html(data.message);
+ $('html, body')
+ .animate({
+ scrollTop: $("#browse-results").offset().top
+ }, 1000);
+ PMA_ajaxRemoveMessage($msg);
+ PMA_makegrid($('#table_results')[0], true, true, true, true);
+ $('#browse-results').show();
+ } else {
+ PMA_ajaxShowMessage(data.error, false);
+ }
+ });
});
}
@@ -69,7 +75,6 @@ function deleteResult(result_path, msg)
$(function () {
/** Hides the results shown by the browse criteria */
$("#table-info").hide();
- $('#browse-results').hide();
$('#sqlqueryform').hide();
$('#togglequerybox').hide();
/** Conformation message for deletion */
@@ -77,13 +82,16 @@ function deleteResult(result_path, msg)
var $msg = PMA_ajaxShowMessage(PMA_messages.strDeleting, false);
/** Load the deleted option to the page*/
$('#sqlqueryform').html('');
- var url = result_path + " #result_query, #sqlqueryform";
- $('#browse-results').load(url, function () {
+ var url = result_path + "#result_query, #sqlqueryform";
+ $.get(url, {'ajax_request': true, 'is_js_confirmed': true},
+ function (data) {
+ if (data.success) {
+ $('#sqlqueryform').html(data.sql_query);
/** Refresh the search results after the deletion */
document.getElementById('buttonGo').click();
$('#togglequerybox').html(PMA_messages.strHideQueryBox);
/** Show the results of the deletion option */
- $('#browse-results').show();
+ $('#browse-results').hide();
$('#sqlqueryform').show();
$('#togglequerybox').show();
$('html, body')
@@ -91,7 +99,10 @@ function deleteResult(result_path, msg)
scrollTop: $("#browse-results").offset().top
}, 1000);
PMA_ajaxRemoveMessage($msg);
- });
+ } else {
+ PMA_ajaxShowMessage(data.error, false);
+ }
+ });
}
});
}
@@ -111,12 +122,10 @@ AJAX.registerOnload('db_search.js', function () {
/**
* Prepare a div containing a link for toggle the search results
*/
- $('
')
- .insertAfter('#searchresults')
+ $('#togglesearchresultsdiv')
/** don't show it until we have results on-screen */
.hide();
- $('
').insertAfter("#togglesearchresultsdiv").show();
/**
* Changing the displayed text according to
* the hide/show criteria in search result forms
@@ -139,8 +148,7 @@ AJAX.registerOnload('db_search.js', function () {
* Prepare a div containing a link for toggle the search form,
* otherwise it's incorrectly displayed after a couple of clicks
*/
- $('
')
- .insertAfter('#db_search_form')
+ $('#togglesearchformdiv')
.hide(); // don't show it until we have results on-screen
/**
diff --git a/libraries/DbSearch.class.php b/libraries/DbSearch.class.php
index a6d877608e..faf7a42db0 100644
--- a/libraries/DbSearch.class.php
+++ b/libraries/DbSearch.class.php
@@ -342,7 +342,7 @@ class PMA_DbSearch
if ($res_cnt > 0) {
$this_url_params['sql_query'] = $newsearchsqls['select_columns'];
$browse_result_path = 'sql.php' . PMA_URL_getCommon($this_url_params);
- $html_output .= '
';
$html_output .= '';
$html_output .= '';
- $html_output .= $this->_getResultDivs();
+ $html_output .= '';
return $html_output;
}
@@ -475,7 +476,7 @@ class PMA_DbSearch
*
* @return string div tags
*/
- private function _getResultDivs()
+ public function _getResultDivs()
{
$html_output = '';
diff --git a/test/classes/PMA_DbSearch_test.php b/test/classes/PMA_DbSearch_test.php
index 6b721d64b8..19fbfed967 100644
--- a/test/classes/PMA_DbSearch_test.php
+++ b/test/classes/PMA_DbSearch_test.php
@@ -153,14 +153,16 @@ class PMA_DbSearch_Test extends PHPUnit_Framework_TestCase
),
true,
' | | 2 matches in table1'
- . ' | Browse | Browse | '
+ . ''
. ' |
'
- . '
',
+ . '
',
$this->object->getSelectionForm($url_params)
);
}