다음 데이터 세트를로드하고 Ajax 호출 후 데이터를 제거하려고합니다. 하지만 아작스는 한 번만 일할 수있었습니다. "더 많은 인용문 가져 오기"를 클릭하면 아무 일도 일어나지 않습니다.ajax는 한 번만 작동 한 다음 클릭 후 중지됩니다.
사이트 : http://kdevs.site40.net/#more
아약스 (자세한 시세 클릭) :
<?php
require("inc/connect.php");
$start = $_GET['start'];
$limit = $_GET['limit'];
$sql = "SELECT * FROM entries ORDER BY id DESC LIMIT ".$start.", ".$limit;
$result = mysql_query($sql, $link) or die("Error in query: ".mysql_error());
$data = array();
while($row = mysql_fetch_array($result)) {
array_push($data, $row);
}
echo(json_encode($data));
?>
나는 그것이 PHP 때문에하지 알고 : http://kdevs.site40.net/quotes.php?start=0&limit=10 작품
function getQuotes(start, limit) {
//Clear the recent list element
$(".recent-list").html("");
$.ajax({
url: "quotes.php?start=" + start + "&limit=" + limit,
success: function (data) {
ata = jQuery.parseJSON(data);
console.log("success");
//Data should now be a javascript array of objects.
for (i = 0; i < data.length; i++) {
var newElem = jQuery("<li></li>").attr('id', data[i].id).addClass('quote-wrap-group');
newElem.append("<div class='quote'><p>" + data[i].quote + "</p></div>");
$(".recent-list").append(newElem);
}
}
});
}
$("#more").click(function() {
var currentIndex = 0;
getQuotes(currentIndex = currentIndex + 10, 10);
currentIndex += 10;
});
PHP는 JSON을 반환합니다.
내가 뭘 잘못하고 있니?
조회에 SQL 주입을 앓고. http://en.wikipedia.org/wiki/SQL_injection을 읽고 수정하십시오. – Kenaniah
^알아요. 전에 이것을 클라이언트에게 보내면 고칠 것입니다 ... – nowayyy