У меня серверная сторона выглядит вот так
<?php
$start=($_POST['start']!= '') ? $_POST['start'] : 0;
$limit=($_POST['limit']!= '') ? $_POST['limit'] : 20;
$zadachnik = $_POST['zadachnik'];
include '../config.php';
$link = mysql_connect($host, $mysql_user, $mysql_password) or die("Could not connect: " . mysql_error());
mysql_select_db($database, $link) or die ('Can\'t use $database : ' . mysql_error());
$sql = "SELECT * FROM `resheniya` WHERE `zadachnik`='$zadachnik' ORDER BY `resheniya`.`id` ASC LIMIT $start , $limit";
$arr = array();
if(!$rs = mysql_query($sql)){
$answer='{success:false}';
}else{
while($obj = mysql_fetch_object($rs)){$arr[] = $obj;}
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
$answer = '{success:true,total:'.$num_rows.', rows:'.json_encode($arr).'}';
}
echo $answer;
?>
|