在PHP中从Textarea发送文本
我想创建一个带有姓名、电子邮件和反馈文本的联系人表单。 现在问题来了。是否可以在不切换站点的情况下将文本发送到mysql数据库(action=sendtext.php)? 我的想法是,用户弹出表单并单击按钮 “提交”。在后台发送一个函数,输入mymysql数据库中的文本,并向用户发出警告(“感谢您的反馈”)。我怎么做在PHP中从Textarea发送文本,php,jquery,mysql,Php,Jquery,Mysql,我想创建一个带有姓名、电子邮件和反馈文本的联系人表单。 现在问题来了。是否可以在不切换站点的情况下将文本发送到mysql数据库(action=sendtext.php)? 我的想法是,用户弹出表单并单击按钮 “提交”。在后台发送一个函数,输入mymysql数据库中的文本,并向用户发出警告(“感谢您的反馈”)。我怎么做 感谢您的帮助您需要使用AJAX发出请求,而无需在j: 在处理表单时,您可能需要编写以下内容: $('#myForm').on('submit', function(event) {
感谢您的帮助您需要使用AJAX发出请求,而无需在j: 在处理表单时,您可能需要编写以下内容:
$('#myForm').on('submit', function(event) {
// Prevent the form from submitting as a normal form (make full page change)
event.preventDefault();
var fromData = $(this).serialize();
$.ajax({
url: 'service.php',
data: formData,
type: 'POST',
success: function(response) {
console.log(response);
}
});
});
$('#myForm').on('submit', function(event) {
// Prevent the form from submitting as a normal form (make full page change)
event.preventDefault();
var fromData = $(this).serialize();
$.ajax({
url: 'service.php',
data: formData,
type: 'POST',
success: function(response) {
console.log(response);
}
});
});