//***************** Java Code ***********************
$.ajax({
type: 'POST',
url: 'file_post_and_return_json.php',
dataType: 'json',
data: ({ID:id }),
success: function(data) {
// use data form array //
$('#DIV').val(data[0].FiledName) ;
}
});
/************* PHP Code ************************
PHP get data form Mysql encode to json
query($sql);
$sql = "SELECT *
FROM tableName
WHERE ID =".$_POST[ID]." ;
";
$numrows = $db->num_rows($sql);
$data_rows = array();
$res = $db->query($sql);
while ($row = mysql_fetch_assoc($res)) {
$data_rows[] = $row;
}
echo json_encode($data_rows);
?>
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น