I am writing a webservice in Slim Framework. But that doesn't concern to the problem. what I am doing is in my webservice I am performing some db tasks and before returning the response in json, I am sending message using socket.io.
Below is my code:
$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
When I checked the json response, it is giving me the same script written above instead of sending push.