[英]How to receive web socket message from server in client side by html5 socket api
[英]how to send message from socket html5 and recive it in a php server
我有一個簡單的php文件服務器和客戶端,我想從客戶端向服務器發送一些數據,以便服務器可以打印這些值
這是我目前所擁有的:
Client.js
var ws = "ws://localhost:9000/demo/server.php";
websocket = new WebSocket(ws);
websocket.onopen = function(ev) // connection is open
{
alert("Connected");
// send a message to the server
}
Server.php
$host = '127.0.0.1';
$port = '9000';
//normal server code
所以我將如何從服務器端接收它?
在WebSockets中使用AJAX 。 使用AJAX,您可以從服務器發送或獲取數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.