时间:2021-07-01 10:21:17 帮助过:21人阅读
$(document).ready(function(){
//post()方式
$('#test_post').click(function (){
$.post(
'ajax.php',
{
id:$("#id").val(),
},
function (data) { //回调函数
var myjson='';
eval('myjson=' + data + ';');
alert(data);
$('#result').html("ID为:" + myjson.username);
}
);
});
});
$a = $_POST["id"];
$conn = mysql_connect("localhost","root","");
$my_db = mysql_select_db("demo",$conn);
$sql="select * from demo where id = $a";
$result = mysql_query($sql, $conn);
$userInfo = mysql_fetch_assoc($result);
print_r($userInfo);
// echo $a;