[英]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.