I have a select form on my website, which looks like this:
<div id="content_big">
<div class="content_top_geel">
Instuurlijnen
</div>
<div class="content_mid">
<div id="insturen">
<select name="employee" id="employee" onchange="getIPL(this.value);">
<option value="">Instuurlijnen</option>
<option value="shout">Shout</option>
<option value="request">Request</option>
</select>
</div>
</div>
</div>
Looks pretty basic. When a user selects a option I want to call a PHP function, and since that isn't possible in JavaScript nor jQuery, I decited to use AJAX:
function getIPL(verzoek)
{
$.ajax({
type: "GET",
url: "verzoek.php",
data: "verzoek =" + verzoek,
success: function(result){
$("#insturen").html(result);
}
});
};
Again, looks pretty darn basic. When the value is changed, it gets the following file:
<?php
if(isset($_GET['verzoek'])){
shoutofrequest($_GET['verzoek']);
}
function shoutofrequest($id)
{
if ($id === 'shout')
{
newShout();
}
elseif( $id === 'request')
{
newRequest();
}
}
function newShout()
{
echo 'SHOUT<br><br><br><br><br><br><br><br><br><br><br><br><br><br>';
}
function newRequest()
{
echo "REQUEST<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>";
}
?>
The functions are to test only.
So this seems good, to my opinion, but when I use the select form, the content jumps away, and I get a white screen...
Did I make any mistakes?
Thanks, Robin.
=. To make sure future content is correctly escaped as well, it's better to usedata: {'verzoek': verzoek},