参见英文答案 >
jQuery Ajax POST example with PHP 11个
我还是JQuery,AJAX和PHP的新手.
我想知道我在这里做错了什么.我正在接收有关客户的信息并尝试在同一页面上返回确认消息.
所以我遇到的问题:
1)点击提交按钮刷新我的页面?为什么?
2)我的提交按钮下方.如何使用addCustomer.php的结果更改其文本?
3)将我的javascript和php代码放在customer.php下的同一个文件中是否可以?
编辑:我也使用Firefox的防篡改数据插件 – 当我点击提交时,由于某种原因没有发送数据.
Customer.php
$(document).ready(function(){
$('#submit').click(function() {
$.ajax({
type : 'POST',
url : 'addCustomer.php',
dataType : 'json',
data:{
add_LN : $('#add_LN').val(),
add_FN : $('#add_FN').val(),
add_PN : $('#add_PN').val(),
add_DOB : $('#add_DOB').val()
},
success : function(data){
//I want to change the "confirmMsg" to the string given back from addCustomer.php
}
}
}
}
Add New Customer:
Last Name: First Name: Phone Number: Date of Birth: |