I am using jQuery Mobile page structure within my code. I am trying to send a parameter to a php file on the server using HTTP GET upon page onload
and want to show my response. However, i see no response. Here is my code:
HTML
<div data-role="page" id="humanities">
<div data-role="header" style="background-color: #eaffcd;">
<image src="http://i.cs.hku.hk/~hsbashir/Project_Work/bayview/hku_logo.png" style="height:40px; width:35px; postion:relative; float:left;">
<h1 style="color:black;"> Departments </h1>
</div>
<ul data-role="listview" data-theme="a" data-split-theme="b" data-split-icon="plus" data-inset="true">
<li class="departments"><a href="#department">Department of Fine Arts</a></li>
<li class="departments"><a href="#department">Department of Law </a></li>
</ul>
</div>
<div data-role="page" id="department" onload="loadCourse()">
<div data-role="header" style="background-color: #eaffcd;">
<image src="http://i.cs.hku.hk/~hsbashir/Project_Work/bayview/hku_logo.png" style="height:40px; width:35px; postion:relative; float:left;">
<h1 style="color:black;"> Courses </h1>
</div>
<ul data-role="listview" data-theme="a" data-split-theme="b" data-split-icon="plus" data-inset="true" id="courselist">
</ul>
<script>
function loadCourse(){
var course = $('.departments').text();
$.get(
"getCourses.php?course="+course,
function( data ){
$('#courselist').html( data )
.listview( 'refresh' );
}
);
}
</script>
</div>
PHP
mysql_connect($host,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$course = $_GET['course'];
$query ='SELECT * FROM Course_info WHERE Department="'.$course.'"';
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
print '<li><a href="#">';
print '<h2 style="text-wrap : normal" >'.$row['Course_code'].' '.$row['Title'];
print '</a></li>';
print '<p>'.$row['Term'].'</p>';
}