diff --git a/geoip.js b/geoip.js
index d85273e..97b02d3 100644
--- a/geoip.js
+++ b/geoip.js
@@ -8,7 +8,7 @@
      * @param param
      *   Optional, value that will be passed to the callback after the data.
      */
-    lookupCountry: function(callback, param) {
+    lookupCountry: function (callback, param) {
       // Save a request if we've got the country stored in a cookie.
       cookie = Drupal.geoip.readCookie('geoip_country');
       if (cookie) {
@@ -17,7 +17,7 @@
       }
 
       // If there's a debug IP address in URL, pass that back to the server.
-      var url =  Drupal.settings.basePath + 'geoip/json/country',
+      var url = Drupal.settings.basePath + 'geoip/json/country',
         debug = /geoip_debug=(?:[0-9]+).(?:[0-9]+).(?:[0-9]+).(?:[0-9]+)/.exec(window.location.search);
       if (debug !== null) {
         url += '?'+ debug[0];
@@ -26,14 +26,18 @@
       $.ajax({
         url: url,
         dataType: 'json',
-        success: function(data) {
+        success: function (country) {
           var expires = null;
           if (Drupal.settings.geoip.lifetime) {
             expires = new Date();
             expires.setDate(expires.getDate() + Drupal.settings.geoip.lifetime);
           }
-          Drupal.geoip.createCookie('geoip_country', data, expires);
-          callback(data, param);
+          // Don't bother caching empty strings since they indicate a problem
+          // with the look up.
+          if (country) {
+            Drupal.geoip.createCookie('geoip_country', country, expires);
+          }
+          callback(country, param);
         }
       });
     },
@@ -48,7 +52,7 @@
      * @param expires
      *   Optional Date object specifying when the cookie should expire.
      */
-    createCookie: function(name, value, expires) {
+    createCookie: function (name, value, expires) {
       var cookie = name + "=" + value + "; path=" + Drupal.settings.basePath;
       if (expires && expires instanceof Date) {
         cookie += "; expires=" + expires.toGMTString();
@@ -65,7 +69,7 @@
      * @return
      *   The value of the cookie, or null if none was found.
      */
-    readCookie: function(name) {
+    readCookie: function (name) {
       var nameEQ = name + '=',
         ca = document.cookie.split(';'),
         i, c;
@@ -81,4 +85,4 @@
       return null;
     }
   };
-}(jQuery));
\ No newline at end of file
+}(jQuery));
diff --git a/geoip.module b/geoip.module
index 8ec769f..a623c0a 100644
--- a/geoip.module
+++ b/geoip.module
@@ -91,7 +91,10 @@ function geoip_add_js() {
  * Callback handler that returns JSON data of the country.
  */
 function geoip_json_country() {
-  drupal_json(geoip_country_code($ip));
+  // Cast it to a string so that NULLs (if the look fails, like when you're on
+  // a private IP) will become empty strings rather. An empty JSON response ({})
+  // would prevent the AJAX complete callback from firing.
+  drupal_json((string) geoip_country_code());
   exit();
 }
 
