I am trying to run/call a PHP file that is going to update a database.
Chrome is giving me this error:
I'm using this code for my index.html
file:
<!DOCTYPE html>
<html>
<body>
<input type="text" id="descriptioninput">
<input type="number" id="budgetin">
<input type="number" id="budgetout">
<button type="button" onclick="addToDB()">Add to database</button>
<script>
function addToDB()
{
var descriptioninput = document.getElementById('descriptioninput').value;
var budgetin = document.getElementById('budgetin').value;
var budgetout = document.getElementById('budgetout').value;
$.ajax ( {
TYPE: 'POST',
url: 'addtodb.php',
data:{descriptioninput:descriptioninput, budgetin:budgetin, budgetout:budgetout},
success:function (data) {
// Completed successfully
alert('success!');
}
});
}
</script>
</body>
</html>
What am I doing wrong here? I've tried to place the code in the <head>
element and specify type="text/javascript"