データをphpファイルに送信してから、結果をIframeに表示しようとしていますが、
しかし成功せず…
私のjquery部分の下:
$( ".load_message" ).click(function() {
//On marque uniquement l'id de l'expediteur et du destinataire
// pour chercher les messages expédiés par A vers B ou inversement
var from = $(this).closest('tr').find('span.from').text();
var to = $(this).closest('tr').find('span.to').text();
$.ajax({
type: 'POST',
url: 'pages_ajax/fetch-messages.php',
data: { from: from, to: to},
dataType: "json"
});
//reload all iFrames
$('iframe').each(function() {
this.contentWindow.location.reload(true);
});
});
次に、Iframe(phpファイル)で
私はこれを持っています:
<?php
session_start();
require_once("../../lib_php/librairie.php");
require_once("../../config/connexion.php");
//header('Content-Type: application/json; charset=utf8');
/**
* Fonction qui retourne une liste de messages
* @return int
*/
function fetchMessages() {
if (isset($_POST['from'])) {
$from = mysql_real_escape_string($_POST['from']);
$to = mysql_real_escape_string($_POST['to']);
$query = "SELECT `id`, `from`, `to`, `message`, `sent`, `read`, `direction`
FROM `cometchat`
WHERE `from` = {$from} || `from` = {$to} || `to` = {$to} || `to` = {$from}";
return $query;
} else {
return null;
}
}
$liste_messages = fetchMessages();
if (!is_null($liste_messages)):
$result_message = mysql_query($query);
while ($mess = mysql_fetch_assoc($result_message)):
?>
ici
<?php
endwhile;
endif;
?>
私が抱えている問題は、iframeが再ロードされず、結果が表示されないことです
どんな種類の助けも大歓迎です