Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery ajax return data not working
    text
    copied!<p>I have a form with two text boxes and two buttons (one submit button, one button). when I call click the button, it has to make an ajax call with data "CheckRegistration". Finally, it will call ViewRegisteredStudents() function. I am expecting the "resultVal" stirng to be returned to ajax call but it is returning the "resultVal" string and form (two textboxes, two buttons).</p> <pre><code> $(document).ready(function(){ $(':button').click(function(){ $.ajax({ Url:"SkiiTripDB.php", type:"POST", data:{call:'CheckRegistration'}, dataType:"html", success:function(data){ $('div#registeredStudents').html(data); } }); }); }); </code></pre> <hr> <pre><code> if(isset($_POST['call'])) { $call=$_POST['call']; $connection=IsDatabaseConnected($strServer,$strUsername,$strPassword,$strDatabaseName); switch($call) { case 'CheckRegistration':ViewRegisteredStudents(); break; } closeDatabaseConnection($connection); } function ViewRegisteredStudents() { $resultVal=""; $resultVal.="&lt;table border='2'&gt;"; $resultVal.="&lt;tr&gt;"; $resultVal.=" &lt;th&gt;Student Name&lt;/th&gt;"; $resultVal.=" &lt;th&gt;Student Class&lt;/th&gt;"; $resultVal.=" &lt;/tr&gt;"; // Query database $strSqlQuery="SELECT sSName, sClass FROM tripregistration"; $result=mysql_query($strSqlQuery); while($row=mysql_fetch_array($result)) { $resultVal.="&lt;tr&gt;"; $resultVal.="&lt;td&gt;".$row['sSName']."&lt;/td&gt;"; $resultVal.="&lt;td&gt;".$row['sClass']."&lt;/td&gt;"; $resultVal.="&lt;/tr&gt;"; } $resultVal.="&lt;/table&gt;"; echo $resultVal; } </code></pre>
 

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