I’ve been using socket.io to act as a server which was working fine. However, I am getting the “unexpected token <” error when adding the line
<script src="client files\MainMenu.js"></script>
to my index.html that connects to the server. This error only occurs in chrome and will run if the aforementioned line is removed.
Strangely though, this error won’t appear in firefox but instead I’ll get errors to do with socket.io.js (which I haven’t touched personally). Also I’ve also successfully used socket.io.js in chrome for other tasks so I don’t think the errors firefox are throwing are actually to do with socket.io. I also haven’t personally edited any of the socket.io code except for the default port number. Any ideas are appreciated.
<html>
<script src="socket.io\lib\socket.io.js"> </script>
<script src="client files\MainMenu.js"></script>
<script>
var socket = io.connect('http://localhost');
socket.on('news', function (data)
{
console.log(data);
socket.emit('my other event', { my: 'data' });
});
</script>
<button onclick="singlePlayerClick()"> Single Player </button>
<button onclick="multiplayerClick()"> Multiplayer </button>
<button onclick="optionsClick()"> Options </button>
<button onclick="highScoreClick()"> High Score </button>
<input id="mysearch" type="search" />
</html>
Sorry for the delayed response and good point in correcting the spacing, I am only just learning HTML now but sadly don’t have a chance to move slowly as our lecturers give relatively detailed assignments in quick succession. As it turns out I had a server.js file which was serving this .html file multiple times which was causing the problem.