Skip to content
Snippets Groups Projects
Commit 3044fa04 authored by Michal Rezler's avatar Michal Rezler
Browse files

using POST instead of GET in searching by ajax

parent 80997d21
No related branches found
No related tags found
No related merge requests found
......@@ -4,16 +4,15 @@
* @license GPL2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
* @author Adrian Lang <lang@cosmocode.de>
* @author Michal Rezler <m.rezler@centrum.cz>
* @author Michal Rezler <m.rezler@centrum.cz>
*/
(function ($) {
(function ($) {
var init, clear_results, onCompletion;
var ajax_quicksearch = {
inObj: null,
outObj: null,
sackObj: null,
delay: null,
};
......@@ -26,21 +25,24 @@
if (ajax_quicksearch.inObj === null) return;
if (ajax_quicksearch.outObj === null) return;
// prepare AJAX
ajax_quicksearch.sackObj = new sack(DOKU_BASE + 'lib/exe/ajax.php');
ajax_quicksearch.sackObj.AjaxFailedAlert = '';
ajax_quicksearch.sackObj.encodeURIString = false;
ajax_quicksearch.sackObj.onCompletion = ajax_quicksearch.onCompletion;
// attach eventhandler to search field
ajax_quicksearch.delay = new Delay(function () {
ajax_quicksearch.clear_results();
var value = ajax_quicksearch.inObj.value;
if(value === ''){ return; }
ajax_quicksearch.sackObj.runAJAX('call=qsearch&q=' + encodeURI(value));
$.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'qsearch',
q: encodeURI(value)
},
function (data) {
onCompletion(data);
},
'html'
);
});
// attach eventhandler to input field
$(ajax_quicksearch.inObj).keyup(
function() {
ajax_quicksearch.clear_results();
......@@ -62,8 +64,7 @@
ajax_quicksearch.outObj.text('');
};
onCompletion = function() {
var data = this.response; // 'this' is sack context
onCompletion = function(data) {
if (data === '') { return; }
var outObj = ajax_quicksearch.outObj;
......@@ -126,5 +127,4 @@
init('qsearch__in','qsearch__out');
});
}(jQuery));
}(jQuery));
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment