title: Uncaught ReferenceError using external script & jQuery Mobile
body: <p>I'm trying to create a web app but can't get my javascript to work.</p>
  
  <p>When loading the page with a fresh started browser I get 'Uncaught ReferenceError: getResult is not defined' (is located in js/ajax.js) but when I refresh the page everything works. I have tried to move where the script loading takes place but I can't get it to work.</p>
  
  <p>I found a bunch of similar questions but they seem to suggest to load script inside  and to not use $(document).ready() and I am doing that already. Anyone? </p>
  
  <p><strong>EDIT:</strong>
  <em>I noticed that the error only occurs when going from another jQuery mobile page.</em></p>
  
  <p><strong>Index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;sio.signalare.se&lt;/title&gt;
      &lt;meta content="width=device-width, user-scalable=no" name="viewport"&gt;
      &lt;meta content="yes" name="apple-mobile-web-app-capable"&gt;
      &lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type"&gt;
      &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css" /&gt; 
      &lt;script src="js/ajax.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/jquery-1.11.1.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"&gt;&lt;/script&gt;
      &lt;style&gt;
          .wrap {
              white-space: normal !important;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div data-role="page"&gt;
      &lt;div data-role="header"&gt;
          &lt;a class="ui-btn-left" data-direction="reverse" data-icon="back"
          data-iconpos="notext" href="../"&gt;&lt;/a&gt;
  
          &lt;h1&gt;ATC-felkoder&lt;/h1&gt;
      &lt;/div&gt;&lt;!-- /header --&gt;
  
      &lt;div data-role="content"&gt;
  
          &lt;ul data-inset="true" data-role="listview"&gt;
              &lt;li&gt;
                  &lt;h2 class="wrap"&gt;F1&lt;/h2&gt;
                  &lt;p class="wrap"&gt;&lt;strong id="F1-result"&gt;&lt;/strong&gt;&lt;/p&gt;
                  &lt;select id="F1" onchange="getResult(this);"&gt;
                      &lt;option value="" selected&gt;Välj&lt;/option&gt;
                      &lt;option value="0"&gt;0&lt;/option&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt;
                      &lt;option value="4"&gt;4&lt;/option&gt;
                      &lt;option value="5"&gt;5&lt;/option&gt;
                      &lt;option value="6"&gt;6&lt;/option&gt;
                      &lt;option value="7"&gt;7&lt;/option&gt;
                      &lt;option value="8"&gt;8&lt;/option&gt;
                      &lt;option value="9"&gt;9&lt;/option&gt;
                      &lt;option value="A"&gt;A&lt;/option&gt;
                      &lt;option value="C"&gt;C&lt;/option&gt;
                      &lt;option value="E"&gt;E&lt;/option&gt;
                      &lt;option value="F"&gt;F&lt;/option&gt;
                      &lt;option value="H"&gt;H&lt;/option&gt;
                      &lt;option value="L"&gt;L&lt;/option&gt;
                      &lt;option value="P"&gt;P&lt;/option&gt;
                      &lt;option value="U"&gt;U&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
  
          &lt;h6&gt;Version 2.0&lt;/h6&gt;
      &lt;/div&gt;&lt;!-- /content --&gt;
  &lt;/div&gt;&lt;!-- /page --&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>js/ajax.js</strong></p>
  
  <pre><code>function getResult(e) {
      if (e.value) {
          var ajax_load = "&lt;img src='img/loader.gif' alt='loading...' /&gt;";
          var loadUrl = "data/result.php?args=" + e.id + "|" + e.value;
          $("#" + e.id + "-result").load(loadUrl);
      } else {
          $("#" + e.id + "-result").empty();
      }        
  }
  </code></pre>