我想运行/调用将要更新数据库的PHP文件。不能调用PHP脚本
我使用此代码为我index.html
文件:
<!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>
什么我错在这里做什么?我试图把在<head>
元素的代码,并指定type="text/javascript"
你没有包含'jQuery'..add this'https:// code.jquery.com/jquery-1.11.3.min.js' –