I have this simple search form inside a custom module.


<div id="search-form">
<form action="" method="post">
<input type="text" name="roll_no">
<input type="submit" name="submit">



// getting text from HTML text box

$roll_no = $_POST['roll_no'];

// executing MySql query to fetch a particular record

$query = $db->getQuery(true);
       ->where($db->quoteName('student_id') . " = " . $db->quote($roll_no));

$result = $db->loadResult();
$row = $db->loadrow();

echo $row['0'];


It works perfectly, but it refreshes the whole page. Can I somehow make it only refresh that particular module (div element).

Help would be appreciated.


To achieve what you want, you can not submit the form.

You have to use an ajax call.

see jQuery.ajax documentation

Get a response and modify the DOM in order to reflect that response.

There is a nice example how to do it here:


  • I have no experience with AJAX, can you explain it with some code?
    – saibbyweb
    Sep 20 '16 at 7:01
  • I edited the answer to add a place with an example Sep 20 '16 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.