Note that there are some explanatory texts on larger screens.

plurals
  1. PORefreshing div without reloading not working
    primarykey
    data
    text
    <p>I'm "fighting" with this for hours now, I hope you could help me with the solution. So I've got a basic form with an empty div that will be then filled:</p> <pre><code>&lt;form method='post' action='/shoutek.php'&gt; &lt;input type='text' id='shout_tresc' name='shout_tresc' class='shout_tresc' /&gt; &lt;input type='submit' id='dodaj' value='Dodaj' /&gt; &lt;/form&gt; &lt;div class='shoutboxtresc' id='shout'&gt;&lt;/div&gt; &lt;span class='loader'&gt;Please wait...&lt;/span&gt; </code></pre> <p>The shoutek.php contains the queries to do after submission of the form and functions to populate the div.</p> <p>Here goes my jquery:</p> <pre><code>$(function() { $(\"#dodaj\").click(function() { // getting the values that user typed var shout_tresc = $(\"#shout_tresc\").val(); // forming the queryString var data = 'shout_tresc='+ shout_tresc; // ajax call $.ajax({ type: \"POST\", url: \"shoutek.php\", data: data, success: function(html){ // this happen after we get result $(\"#shout\").toggle(500, function(){ $('.loader').show(); $(this).html(html).toggle(500); $(\"#shout_tresc\").val(\"\"); $('.loader').hide(); }); return false; } }); }); }); </code></pre> <p>The problem in that is that it directs me to shoutek.php, so it does not refresh the div in ajax.</p> <p>As you can see, I used return false; - i also tried the event.preventDefault(); function - it did not help. What is the problem and how to get rid of it? Will be glad if you could provide me with some solutions.</p> <p><strong>EDIT</strong></p> <p>Guys, what I came up with actually worked, but let me know if that's a correct solution and will not cause problems in the future. From the previous code (see Luceous' answer) i deleted</p> <pre><code>$(function() { </code></pre> <p>(and of course it's closing tags) and I completely got rid of the:</p> <pre><code>&lt;form method='post' action='/shoutek.php'&gt; </code></pre> <p>Leaving the input "formless". Please let me know if it is a good solution - it works after all.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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