Call ajax from other page through javascript

here is my javascript function

 function PushMessage(e , textarea) 
        {
            var code = (e.keyCode ? e.keyCode : e.which);
            if(code == 13) { //Enter keycode
            var text1 = document.getElementById('myTextArea').value;
            var div = document.getElementById('textmesage');
            div.innerHTML = div.innerHTML + '<br>' + text1;
            document.getElementById('myTextArea').value = "";
            if (text1.length !== 0) {
            that.sendMessage(text1);
            event.preventDefault();
        } else {
            alert('Provide a message to send!');
        }
                            }
        },

i want to call ajax function through upper javascript . here is my ajax fucntion which is consist on other page

 sendMessage: function(message) {
    alert('fakhir is jumping');
    var that = this;
    $.ajax({
      url: '/ajax/add_msg.php',
      method: 'post',
      data: {msg: message},
      success: function(data) {
        $('#chatMsg').val('');
        that.getMessages();
      }
    });
  },

some guide me how to do this. i am new in php .

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.