title: PhoneGap/Cordova: Fine in Simulator, suddenly not working on device: Can't find jQuery
body: <p>This just suddenly began happening: my boss took her phone with the development copy of the app on a short business trip, and reported this error a couple days into the trip. I assumed I had made some changes to the json returning from the server and that broke it, but now that I have it back, it doesn't seem to be related to my work on the server at all.</p>
  
  <p>Here is the error message I get in the console:</p>
  
  <pre><code>Error in success callback: Geolocation3 = ReferenceError: Can't find variable: jQuery
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Error in success callback: Geolocation3 = ReferenceError: Can't find variable: $
  </code></pre>
  
  <p>So clearly, it just can't find jQuery. It executes 'deviceReady' just fine. But it works fine in the simulator. I am using the jQuery CDN for both jQM and jQ and can access both via a browser.</p>
  
  <p>So what gives? Why would it suddenly not be able to find jQuery - and only on the device?</p>
  
  <p>I see A LOT of similar questions on the web, but none of them have a clear answer. Some is "clean and rebuild" others are simple typos.... but nothing for this. It's not a location permissions issue. It's not a connection issue. It's not a url whitelist issue.</p>
  
  <p>Your help is appreciated as always. Thanks!</p>
  
  <hr>
  
  <p>I'll give as much code as I can below:</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"&gt;
      &lt;title&gt;XXXXXX&lt;/title&gt; 
      &lt;link rel="stylesheet" href="css/jquery.mobile.css" /&gt;
      &lt;link rel="stylesheet" href="css/themes/app-2012-11-30.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="spec/lib/photoswipe/photoswipe.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/index.css" /&gt;
      &lt;!-- cordova --&gt;
      &lt;script src="cordova-2.1.0.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;!-- jquery --&gt;
      &lt;script src="http://code.jquery.com/jquery-1.8.2.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"&gt;&lt;/script&gt;
      &lt;!-- Google --&gt;
      &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"&gt;&lt;/script&gt;
      &lt;!-- Add ons --&gt;
      &lt;script src="spec/lib/photoswipe/lib/klass.min.js"&gt;&lt;/script&gt;
      &lt;script src="spec/lib/photoswipe/code.photoswipe.jquery-3.0.5.js"&gt;&lt;/script&gt;
      &lt;!-- Objects --&gt;
      &lt;script src="js/map.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/prefs.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/search.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/storage.js" type="text/javascript"&gt;&lt;/script&gt; 
      &lt;script src="js/helpers.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/player.js" type="text/javascript"&gt;&lt;/script&gt; 
      &lt;script src="js/record.js" type="text/javascript"&gt;&lt;/script&gt;  
      &lt;script src="js/connection.js" type="text/javascript"&gt;&lt;/script&gt; 
      &lt;script src="js/location.js" type="text/javascript"&gt;&lt;/script&gt;  
      &lt;script src="js/header-footer.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/featured.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/list.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/index.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          document.addEventListener("deviceready", onDeviceReady, false);
          function onDeviceReady(){
              console.log('device ready');
              storageSetUp();
              checkConnection();
              getLocation();
              showFeatured();
              getSetUp();
              clUpdate();
              $(document).bind( 'mobileinit', function(){
                  $.mobile.defaultPageTransition = "none";
                  $.mobile.loader.prototype.options.textVisible=false;
                  $.mobile.loader.prototype.options.html = '&lt;div class="loading"&gt;&lt;/div&gt;';
                  $.mobile.pushStateEnabled = false;
              });
              $(document).bind('pagebeforeshow',function(){
                  setHeaderFooterInfo();
              });         
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>getLocation is in a .js file. You see the function getStreetAddress there, it contains an ajax call ($.ajax or jQuery.ajax) and this is where it gives the error.</p>
  
  <pre><code>function getLocation()
  {
      gLAttempt++;
      navigator.geolocation.getCurrentPosition(onLocationSuccess, onLocationError);
  } 
  
  // onSuccess Geolocation
  function onLocationSuccess(position)
  {
      var lat = position.coords.latitude;
      var lng = position.coords.longitude;
      Storage.location.lat = parseFloat(lat.toFixed(6));
      Storage.location.lng = parseFloat(lng.toFixed(6));
      Storage.location.coords = lat.toFixed(6) + ',' + lng.toFixed(6);
      if(ajax_rg == null){
          getStreetAddress(Storage.location.coords);
      }
  }
  </code></pre>