Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I assume "my web-app never do a postback" means you will use AJAX :)<br/> There's no difference in using AJAX or server calls but I prefer the use of AJAX to keep a neat UI.</p> <p>Now, after reading your post, you need to know something.</p> <p>You have these two files:</p> <p>file1.js</p> <pre><code>var a = 'Cheers'; var b = ' and beers'; </code></pre> <p>file2.js</p> <pre><code>alert(a + b); </code></pre> <p>To include this files in your html file <pre><code>&lt;script type="text/javascript" src="file1.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="file2.js"&gt;&lt;/script&gt; </pre></code></p> <p>is the same thing as doing <pre><code>&lt;script type="text/javascript"&gt; var a = 'Cheers'; var b = ' and beers'; &lt;/script&gt; &lt;script type="text/javascript"&gt; alert(a + b); &lt;/script&gt; </pre></code></p> <p>And this, in fact, is the same as doing <pre><code>&lt;script type="text/javascript"&gt; var a = 'Cheers'; var b = ' and beers'; alert(a + b); &lt;/script&gt; </pre></code></p> <p>Notice that inversing the order of the source files like this <pre><code>&lt;script type="text/javascript" src="file2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="file1.js"&gt;&lt;/script&gt; </pre></code></p> <p>will generate</p> <p><pre><code>&lt;script type="text/javascript"&gt; alert(a + b); var a = 'Cheers'; var b = ' and beers'; &lt;/script&gt; </pre></code></p> <p>and you will get a runtime excepcion (a is undefined).</p> <p>So, yes, you can have multiple js files, and organize your code.<br/> I usually do it having a single javascript class in a file, like in Java.</p> <p>Good Luck :)</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. VO
      singulars
      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