Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting php data from database using jquery without ajax

I am developing a query PHP enabled chat, currently am using ajax to pull data from the server and display it in the chatbox but this makes use of multiple ajax requests to the client computer which causes it to slow abit....

This is what I am doing using ajax and yii2

 function getdata() {
    $.get("controller/action").
    done(function(){
       //process json

        $("#chatbox").html(data);
    })
  }

then am using

windows.setInterval(getdata(),1000);

Are there better ways to fetch this son data without using ajax and jquery

I have checked on This link buts its not very helpful

like image 712
Geoff Avatar asked Oct 29 '22 18:10

Geoff


1 Answers

You can use socket.io or websockets api which is an alternate option to ajax, So, by using socket.io, jquery, php OR nodejs one can build one to one private chat without using ajax, following links will help you out how to build private chat.

socket.io

WebSockets

Private chat reference 1

Private chat reference 2

like image 167
himeshc_IB Avatar answered Nov 12 '22 13:11

himeshc_IB