I want to update my database without refreshing the page when selecting an option from my drop down menu. So I will use Ajax. The problem is that without refreshing the page and without seeing the PHP code running, I cannot see if there are any errors in my code in order to fix them. Is there any way to see the data that I pass when selecting an option from my drop down to my PHP file, and see any errors the PHP file reports when processing that data?
I have tried to check the console of my browser but it doesn't display anything.
My drop down:
echo "<select id='vacationId' name='vacationId' style='background:lightblue'>
<option selected='selected' value='' style='background:lightblue'></option>
<option value='" . $vacationIdP . "' style='background:lightblue'>P</option>
<option value='" . $vacationIdO . "' style='background:lightblue'>O</option>
<option value='" . $vacationIdA . "' style='background:lightblue'>A</option>
<option value='" . $vacationIdR . "' style='background:lightblue'>R</option>
</select>";
Ajax code to pass the option Value to a PHP file:
$('#vacationId').change(function(){
var option = $('#vacationId').val();
console.log(option);
$.ajax({
type: 'GET',
url: 'saveVV.php',
data:
{
option:option // Does this pass the value of the option ?
// Can I access this in my PHP file with $vacationId = $_GET['option'];
}
}).done(function(resp){
if(resp == 200) {
console.log('Success!');
}else if(resp == 0){
console.log('Failed..');
}
});
});
What I want is to pass the Value of the selected option to my PHP file and then do some processing to it in PHP. And I want to see that I pass the correct info to my PHP file. And I would like to see the PHP code running with that info and maybe displaying some errors.