Note that there are some explanatory texts on larger screens.

plurals
  1. POSocket.io - Cannot load file
    primarykey
    data
    text
    <p>I made a web chat application using Node.js, socket.io and express. It's working well.<br> Now I want to move my chat application into my website but i have problem with paths.<br> My website is based on <strong><a href="http://four.laravel.com" rel="nofollow">Laravel framework</a></strong> and has this structure. </p> <pre><code>Website /public /js /jquery1-10.js /chat.js ----&gt; client side chat file. /app.js ----&gt; node.js server side file. /index.php </code></pre> <p>Laravel use layouts so in <code>index.php</code> file, <code>URL::asset('/path-to-file')</code> is working well for all files inside public directory. including stylesheets and javascript.</p> <p>Inside my <code>index.php</code> file I call javascripts this way:</p> <pre><code>&lt;script src="{{ asset('js/jquery1-10.js'); }}" &gt;&lt;/script&gt; // public/js/jquery1-10.js &lt;script src="{{ asset('js/chat.js'); }}" &gt;&lt;/script&gt; // public/js/chat.js &lt;script src="{{ asset('/socket.io/socket.io.js'); }}" &gt;&lt;/script&gt; // ??? </code></pre> <p>both <code>jquery1-10.js</code> and <code>chat.js</code> loads well<br> BUT can't load socket.io file. I think socket.io creates automatically! and I have no idea where it is.<br> Can somebody help me with this?</p> <p>this is <code>app.js</code> file:</p> <pre><code>var http = require("http"); var express = require("express"), app = express(), server = http.createServer(app), io = require("socket.io").listen(server); server.listen(4000); app.get("/*", function( req, res ) { res.sendfile( __dirname + "/index.php" ); }); </code></pre> <p>And this is my chat.js file --> client side.</p> <pre><code>jQuery( function($){ var socket = io.connect(); ---&gt; error happens here. can not load socket.io.js file </code></pre> <hr> <h1>Solved</h1> <p>well, I used this line:<br> <code>&lt;script src="http://localhost:4000/socket.io/socket.io.js" &gt;&lt;/script&gt;</code></p> <p>instead of this:<br> <code>&lt;script src="{{ asset('/socket.io/socket.io.js'); }}" &gt;&lt;/script&gt;</code></p> <p>and it worked well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload