2017-03-15 19 views
0

JavaScriptをダウンロードしました。popup notification file私はそれを処理するコードを統合しようとしています。だから、私はこの非常にユーザーがログインするか、送信ボタンをクリックするたびにメッセージをポップアップするこのPHPスクリプトを持っています。どのような私が達成したいことはJavaScriptでPHPの出力をエコーし​​ているされてポップアップするので、私は message : '<?php if(isset($_GET['msg'])) echo $_GET['msg'];?>',message : '<p>This is the pop up message</p>',を交換で動作していない、このダンプコードを試してみました:JavaScriptの通知スライダーにPHP出力を表示するにはどうすればいいですか?

これは私のPHPですコード:

<?php 
    $username = $_POST['l-form-5-username']; 
    $password = $_POST['l-form-5-password']; 

    // Harryson harry_admin 
    if ($username =='[email protected]' AND $password =='shatter'){ 
          //Output Success Msg 
          $Msg = "'<p><i class=\"fa fa-check\"></i> <a href=\"#\">Download</a> has been sent to your email account. Please check your inbox/spam folder.</p>'"; 
          header("Location:indextrial.php?Msg=$Msg"); 
       }else{ 

         //Output Not A Client Error Msg 
         $Msg = "'<p><i class=\"fa fa-lock\"></i> This File is Confidential. You're Not Our Client, therefore you have no access to this file thanks!</p>'"; 
         header("Location:indextrial.php?Msg=$Msg"); 
       } 
?> 

これは私のjavascriptのコードです:

<script>// create the notification 
var notification = new NotificationFx({ 
    var msg = ; 

    // element to which the notification will be appended 
    // defaults to the document.body 
    wrapper : document.body, 

    **// THIS IS WHERE I TRIED TO ECHO OUT THE PHP MESSAGE** 
    *message : '<?php if(isset($_GET['msg'])) echo $_GET['msg'];?>',* 

    // layout type: growl|attached|bar|other 
    layout : 'growl', 

    // effects for the specified layout: 
    // for growl layout: scale|slide|genie|jelly 
    // for attached layout: flip|bouncyflip 
    // for other layout: boxspinner|cornerexpand|loadingcircle|thumbslider 
    // ... 
    effect : 'scale', 

    // notice, warning, error, success 
    // will add class ns-type-warning, ns-type-error or ns-type-success 
    type : 'error', 

    // if the user doesn´t close the notification then we remove it 
    // after the following time 
    ttl : 6000, 

    // callbacks 
    onClose : function() { return false; }, 
    onOpen : function() { return false; } 

}); 

// show the notification 
notification.show();</script> 

答えて

0

私が来ましたこの関数をクロスする。 json_encode()は、PHP文字列を正しいJavaScript文字列に変換したので、JavaScriptに引用符を含めないようにしていました。ちょうどこれだけで魔法をやったのですが、結局私のコードはダンプされませんでした!

// This was how my message now looked! 
    message : <?php if(isset($_GET['msg'])) echo json_encode($_GET['msg']);?>, 
関連する問題