こんにちは、jquery に関数があり、$.Post を使用して、クエリが正常に機能し、データを送り返す php ファイルにデータを送信します。
js
function send_agenda_data(cidade_data){
var data = {'cidade_data':cidade_data};
$.post('includes/agenda_data.php',data,function(info){
});
}
この機能は正常に機能し、データが戻ってくることを警告すると、それも正常に機能します
ここにphpがあります
<?php
include_once("connection.php");
$cidade_data = $_POST['cidade_data'];
if (isset($cidade_data)) {
$sql = mysql_query("select * from agenda where cidade = '$cidade_data'", $con) or die(mysql_error());
if (mysql_num_rows($sql) > 0) {
while ($data = mysql_fetch_object($sql))
{
$date = $data->data;
$cidade = htmlentities($data->cidade);
$estado = htmlentities($data->estado);
$local = htmlentities($data->local);
$endereco = htmlentities($data->endereco);
$site_local = htmlentities($data->site_local);
$site_ingresso = htmlentities($data->site_ingresso);
$endereco = htmlentities($data->endereco);
}
}
else{
echo "No Data";
}
}
?>
これは、phpを使用して直接使用し、タグ内の変数を今すぐエコーする場合に正常に機能します
$.post('includes/agenda_data.php',data,function(info){
//need data here
});
ここでjsでphpから返されたデータを取得する方法と、そのデータをタグに割り当てる方法を知りたいです。また、php に while ループがあることを知りたい場合は、すべての行に入力するためのループもここにありますか?
Webページで直接phpを使用する場合、whileループでこのように使用できます
<div><?php echo $date; ?></div>
<div><?php echo $cidade; ?></div>
<div><?php echo $estado; ?></div>
<div><?php echo $local; ?></div>
.
.
.
どうすれば $.Post ケースに入ることができますか