Server-side and front-line data exchange

Asked 1 years ago, Updated 1 years ago, 22 views

On the server side, we use languages such as PHP and Ruby, but
On the browser side, JavaScript is the choice.

How do I exchange data with JavaScript?
I would just embed JSON on the page and parse it, or communicate with ajax to retrieve data.

I haven't experienced it yet, so based on various situations,
Please let me know how to do it and how to do it.

javascript

2022-09-30 16:47

2 Answers

In addition to the methods mentioned in the question

You can also use the .

Roughly speaking
WebSocket is an efficient two-way communication method. WebRTC sells P2P (direct client-to-client communication) for fighting games, video chat, and more.

It seems that ajax has recently introduced a new API called fetch as well as XMLHttpRequest.

Note: Fetch API commentary or what is "Fetch" on the web?- Block Rockin' Codes


2022-09-30 16:47

There are other SSE(Server Sent Events).It is publisher/subscriber type and can be pushed out.There are EventSource API specifications at the link.

An example of using JSON for payload is here.We are distributing the current value of bitcoin in stream.


2022-09-30 16:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.