私は次のような別のphpページに(成功した場合)リダイレクトするphpページを持っています:
header('Location: completed.php?message=Successful operation. Data inserted for user: ' . $login->get_username() . ' . See home page for infos.');
これでcompleted.phpに、受信したメッセージをエコーするdivがあります。
<div id="msg">
<?php echo $_GET['message']; ?>
</div>
'Toastmessage-plugin':here ..を使用していますが、Toastmessageのテキストに$ _GETを表示できません..このコードを使用しています:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="js/jquery.toastmessage.js" type="text/javascript"></script>
<link href="styles/jquery.toastmessage.css" rel="stylesheet" type="text/css" />
...
<script type="text/javascript">
function showStickyNoticeToast() {
$().toastmessage('showToast', {
text: $('#msg').val(),
sticky: true,
position: 'bottom-left',
type: 'notice',
closeText: '',
close: function () { console.log("toast is closed ..."); }
});
}
</script>
DOMイベントやその他のイベントもたくさん検索しましたが、どのような手順を踏むのかわかりません...多分JQ関数がロードされたとき、div'msg'はまだGETデータを受信していません...?だから私は彼の値をどのように更新しますか?
私が読んだページ: これとこれ。私もajaxを試してみましたが、その言語の経験はあまりありません。
助けてください...:)ありがとう
@charlietflを編集
Ajax:何度も試しました...コードが見つかりません!基本的に私はこのコードでphpファイルを呼び出します(これを擬似コードと見なします):
<script type="text/javascript>
<!--
$('#choose').change(function(event) {
$.get('messages.php', { selected: $('#msg').val() },
function(data) {
$('#update').html(data); // other div wher store data
}
);
});
</script>
...。
<?php
$alfa = isset($_GET['message']) ? $_GET['message'] : 'nothing';
echo $alfa;
?>