Note that there are some explanatory texts on larger screens.

plurals
  1. POload() in jQuery
    text
    copied!<p>I have some questions about jQuery and the <code>load()</code> function.</p> <p>I have a form which sends 3 params that are needed for a query. I wanted to load the data to a specified <code>div</code> without reloading a page so I tried with <code>load</code> function in jQuery. It seems ok but there are some questions that I need to ask.</p> <p>I made a <code>div</code> with id "response" that I will use to load data. I've done something like this:</p> <pre><code>$(document).ready(function() { $("#response").load(("search.php?param1=1&amp;param2=2&amp;param3=3$search=send")) }); </code></pre> <p>And it works fine. But I have tried to do it in a function</p> <pre><code>function search() { $("#response").load(("search.php?param1=1&amp;param2=2&amp;param3=3$search=send")) } </code></pre> <p>and then use it when dom tree is ready. The query returned what I wanted it to, but on the new page. Well, during writing that I tried using <code>return false</code> which should block the page and keep it from reloading (Am I wrong here ?).</p> <p>When the <code>return false</code> statment is in the search function and the function is used</p> <pre><code>$(document).ready(function() { search(); }) </code></pre> <p>it doesn't work. But when I place a return statement after the <code>search()</code> call, it works the way it should. Can someone tell me why?</p> <p>After that, I was wondering if there is a chance to do the same thing using the <code>ajax</code> function in jQuery.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload