<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<button id="buts">
ajax-post
</button>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
//绑定一个单击事件
$('#buts').click(function(){
//$.post()方式请求ajax基本与$.get()的方式等并无差异
//$.post('文件路径',{传值},回调函数function(){},json)
//ajax传递的值可以使用$_POST()的方式在PHP中打印出来
$.post('05_posts.php',{uname:'jokerwang'},function(data){
console.log(eval(data));
},'json')
})
</script>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号