我想要一个jQuery脚本,它接收一个php脚本的返回,该脚本通过$.post("script.php", args)
发出请求的数据库请求,但是如何处理任何答案?
答案 0 :(得分:3)
在进入某些内容之前,您应该真正阅读这些教程
回答你的问题
jQuery post采用如下参数
jQuery.post(url [,data] [,success(data,textStatus,jqXHR)] [, dataType])
具有某些参数的典型jquery post请求,期望XML格式的php文件(在本例中为test.php)的结果如下所示
$.post("test.php",
{ name: "John", time: "2pm" },
function(data) {
process(data);
},
"xml"
);
希望这有帮助。
答案 1 :(得分:1)
$.post("script.php", args, function(res) {
// res is the response send to your from server
// now do your stuff
});
答案 2 :(得分:1)
许多人建议查看jQuery手册,了解POST或AJAX调用的可能用法, 这是我的ajax调用示例:
$.post("server.php", { "func": "getNameAndTime" }, function(data){
console.log(data.name); // John Doe
console.log(data.time); // 2001-01-01 23:00:00
}, "json");
<强> server.php 强>
//do some processing and validation
$response = array('name' => 'John Doe', 'time'=> '2001-01-01 23:00:00');
print json_encode($response);
exit;