【发布时间】:2015-06-28 18:28:45
【问题描述】:
我的问题是如何从 php 文件到 jquery ajax 脚本获取 db 信息(在我的情况下只是一个数字)所以这是我的 jquery:
function rate_down(id) {
var id = id;
//submit data to php script
var data = {
"id": id,
};
$.ajax({
type: "POST",
url: "rating.php",
data: data,
success: function(response) {
var currentValue = /* here i want to put the db number */
var newValue = +currentValue - 1;
$("#points_"+id).text(newValue);
},
error: function(jqXHR, textStatus, errorThrown){
alert(errorThrown);
}
});
};
我想要我的 raiting.php。我不确定是否应该发布它,因为它没用,但这是我在 raiting.php 中的 mysql 查询:
$pic_id = (int) $_REQUEST['id'];
mysql_query = mysql_query"SELECT points FROM `photos` WHERE `id` = '$pic_id'";
【问题讨论】:
-
安全提示:使用这样的 MySQL 查询容易发生 SQL 注入。非常不鼓励在系统的生产环境中使用 ;)
标签: php jquery mysql ajax json