GEOFFREY MWANGI GEOFFREY MWANGI - 1 month ago 19
Ajax Question

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

Answer

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