A
A
Azat Kiberov2021-03-20 17:56:44
JavaScript
Azat Kiberov, 2021-03-20 17:56:44

How to send your request for a site with socket io through the browser?

Hello there is one site there need to send a request for a site with a websocket .How to manually send a request? This is possible with normal post requests, but how to send with a websocket you need to know. There is such code in the code.
How to send it manually from the browser without any buttons.

send({
    type: "chat",
    user: utilizator,
    message: sendInput
  });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2018-02-21
@GigFuns

First, super is a reserved word.
Secondly, why did you decide that the code does not work, maybe just the variable is not equal to 1.
Thirdly, please show the context, it looks pretty funny when the alert "Exactly???" immediately flies out when the page is loaded. =)
//upd

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="JS/ScriptTest.js"></script>
    <link rel="stylesheet" href="CSS/StyleTest.css">
    <title>Document</title>
</head>
<body>
    <input type="text" id="OP" onkeyup="if (this.value == 1) alert('Точно ?')">
</body>
</html>

W
WarriorKodeK, 2018-02-21
@WarriorKodeK

1. Don't capitalize variables + Super(super) is a reserved word
2. What kind of tag do you store in Super?
If it's not input, then use textContent.
textContentreturns a string, so parse it (parseInt) before checking.
UPD:

var userText = document.getElementById('OP').value; 
if(parseInt(userText) === 1){
  alert("wooow")
};

Only with window.onload, it will not work for you, because with it the input is always clean. Better put the handler on the button or set the default value
<input type="text" id="OP" value="1">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question