1

here is my php file

       <?php
         require_once __DIR__ . '/../../core/FbChatMock.php';
         if (isset($_POST['id'])) 
           {
              $userId = (int) $_SESSION['user_id'];
              $id = htmlentities($_POST['id'],  ENT_NOQUOTES);
              $chat = new FbChatMock(); 
              $messages = $chat->getchat($userId, $id);
              echo json_encode($messages);
           }
              $chat_converstaion = array();
              $chat_converstaion[] = '<table>';
        ?>

i want to pass these $id and $userId variable to javascript file here is my javascript file

         getMessage:function(ID) 
            {
              var that = this;
              $.ajax({
                      url: '../forms/ajax/send_id.php',
                      method:'post',
                      data: {id: ID},
              success:function(data) {
                           var messages = JSON.parse(data);
              for (var i = 0; i < messages.length; i++)
                {
                  var msg = messages[i];
                  fbChat.addUserMessage('',msg.message);
                }
             $('.msg_head').val('');
                                     }
             });
            },
             addUserMessage:function (user, message) 
            {
              msgBoxList = $('.msg_box').find('.msg_body');
              msgBoxList.append("<div class='msg_a'>"+message+"</div>");
            }
        };

I want to use these parameter at place of empty parameter inside addusermessage function inside.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 2
    Possible duplicate of [How to pass variables and data from PHP to JavaScript?](https://stackoverflow.com/questions/23740548/how-to-pass-variables-and-data-from-php-to-javascript) – Sagar V Jul 13 '17 at 11:56

0 Answers0