在php webservice

时间:2017-11-14 11:41:31

标签: javascript php json socket.io

我正在Slim Framework中编写一个Web服务。但这与问题无关。我正在做的是在我的网络服务中我正在执行一些数据库任务,在返回 json 中的响应之前,我正在使用 socket.io 发送消息。

以下是我的代码:

$db = new DbHandler();
$response = $db->savehairPatient();
echoRespnse(200, $response);
 ?>
    <script src="../node_modules/socket.io/node_modules/socket.io-client/socket.io.js">
    </script>
    <script>

    history.pushState('', '', 'patient');
    var socket = io.connect('http://' + window.location.hostname + ':3000');

    socket.emit('new_count_message',
        {
            new_count_message: '2'
        });

    socket.emit('new_message',
        {
            name: "name",
            email: "email",
            subject: "23dfad",
            created_at: "12",
            id: pid
        });
    </script>
 <?php

当我检查json响应时,它给了我上面写的相同脚本而不是发送push。

0 个答案:

没有答案