更新时间:2023-10-21 19:06:16
对于提交表单和数据库连接:
您可以使用的onclick 函数来处理行动的提交按钮:
you can use onclick function to handle actions for submit button :
例如,在.js文件
$(document).ready(function(){
$('#submit').click(function(){
var input = $('#textfiel').val();
$.post("ajaxHandle.php",
{data:input }
).success(function(responce){
$('#responceMessage').prepend(responce);
/* This is the field on your index.php page where you want to display msg */
});
});
});
ajaxHandle.php文件:
ajaxHandle.php file:
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$inputData = $_POST['data'];
/* your database code will be done here you can find user input data in $inputData */
echo "registration successful"; /* this string will be get in var responce in .JS file */
}
要动态重定向页面:
您可以使用.load()函数,例如:
you can use .load() function for example :
$('#content').load('../app/register.php');
使用此 http://api.jquery.com/load/ 参考使用。