I have the following code in my main page
<html>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
function loadQueryResults() {
$('#DisplayDiv').load('toaction.php');
return false;
}
</script>
<body>
<div id="page">
<form id="QueryForm" method="post">
<div id="SubmitDiv" style="background-color:black;">
<input type = "text" name="song"></input>
<button type="submit" form="QueryForm" onclick="return loadQueryResults();">Submit Query</button>
</div>
</form>
<div id="DisplayDiv" style="background-color:red;">
</div>
</div>
</body>
</html>
And the following in my toaction.php
<html>
<meta charset="utf-8">
<body>
<div id="page" style="background-color:yellow;">
<?php
if( isset($_POST['song']) )
{
$song = $_POST['song'];
echo $song;
}
else
{
echo "form didn't submit";
}
?>
</div>
</body>
</html>
The idea is to dynamically refresh the div without reloading the page. Which works, but the variable "song" is not passed through - so the div updates with "form didn't submit".
Thanks in advance,