Note that there are some explanatory texts on larger screens.

plurals
  1. POcontrolling form submit action inside a div using Jquery
    text
    copied!<p>I am trying to load everything in my website inside a div with fading effect, i have made a jquery function to handle all click events inside the div such as links, buttons, and form submits. everything work fine except for form submits, for example i have this form in one of my pages: </p> <pre><code>&lt;form name="form" method="post" action=""&gt; &lt;p&gt;Enter a Start date for review &lt;font color="red"&gt;&lt;b&gt;(mm/dd/yyyy)&lt;/b&gt;&lt;/font&gt; : &lt;input type="text" name="StartDate" id="startDate" maxlength="10" size="15"&gt; &lt;br /&gt; &lt;label id="label1" style="color: red"&gt;&lt;/label&gt; &lt;p&gt;Enter a deadline for review &lt;font color="red"&gt;&lt;b&gt;(mm/dd/yyyy)&lt;/b&gt;&lt;/font&gt; : &lt;input type="text" name="txtDate" id="txtDate" maxlength="10" size="15"&gt; &lt;br /&gt; &lt;label id="label2" style="color: red"&gt;&lt;/label&gt; &lt;/p&gt; &lt;/br&gt; &lt;/br&gt; &lt;/br&gt; &lt;input type ="submit" name="submitCrit" value="submit"&gt;&lt;/input&gt;&lt;/br&gt; &lt;/form&gt; &lt;?php if (isset($_POST['txtDate']) &amp;&amp; isset($_POST['StartDate'])) { // checking if values passed $todays_date = date("m/d/Y"); // getting today's date to check with it $today = strtotime($todays_date); // parsing it to timestamp $to = date('Y-m-d', str_replace('-', '/', $today)); // replacing / with - $date = strtotime($_POST['txtDate']); // parsing enddate to timestamp $newdate = date('Y-m-d', str_replace('-', '/', $date)); // replacing / with - $startdate = strtotime($_POST['StartDate']); // parsing startdate to timestamp $startnewdate = date('Y-m-d', str_replace('-', '/', $startdate)); // replacing / with - if ($newdate != null &amp;&amp; $newdate &gt; $to &amp;&amp; $startnewdate != null &amp;&amp; $startnewdate &lt; $newdate &amp;&amp; $startnewdate &gt; $to) { $con = mysql_connect('localhost', 'root', ""); //db connection if (!$con) { die('connection error'); } else { mysql_select_db("mydb", $con); $query = " UPDATE conference SET rev_startDate = '{$startnewdate}', rev_endDate = '{$newdate}' WHERE conference_id = {$confID} "; echo '&lt;script type="text/javascript"&gt;' , 'ChangeText("deadline set successfuly");' , '&lt;/script&gt;'; if (!mysql_query($query, $con)) { echo "query not run"; } mysql_close($con); } } else { echo '&lt;script type="text/javascript"&gt;' , 'ChangeText("invalid deadline");' , '&lt;/script&gt;'; } } ?&gt; </code></pre> <p>and this thw function to handle the click event: </p> <pre><code>$(document).ready(function() { $('#mydiv').delegate('form', 'submit', function() { var page = $(this).attr('action'); if (page == "") { return true; } else { $('#mydiv').fadeOut('slow',function() { $('#mydiv').load(page, function () { $(this).fadeIn('slow'); }); }); return false; } }); return false; }); </code></pre> <p>however when i click submit, only blank page is loaded inside the div &amp; the php script didn't work, and the same problem happens for all other forms in the website. anyone knows where is the problem?</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