Skip to content
Browse files

Now loads language json for local file urls (file://...)

* test files no longer require http server to work, so
  people can run the tests themselves with less fuss.

* test/absolute_prefix_path.html still requires http server.
  • Loading branch information...
1 parent 87add63 commit 132358e0ef88b2d73bc2d7a4dbc6a1569db10039 @coderifous committed Feb 9, 2011
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/jquery.localize.js
View
12 src/jquery.localize.js
@@ -36,13 +36,21 @@
function jsonCall(file, pkg, lang, level) {
if (options.pathPrefix) file = options.pathPrefix + "/" + file;
- $.ajax({
+ var ajaxOptions = {
url: file,
dataType: "json",
async: false,
timeout: (options && options.timeout ? options.timeout : 500),
success: successFunc
- });
+ };
+
+ // hack to work with serving from local file system.
+ // local file:// urls won't work in chrome:
+ // http://code.google.com/p/chromium/issues/detail?id=40787
+ if (window.location.protocol == "file:")
+ ajaxOptions.error = function(xhr){ successFunc($.parseJSON(xhr.responseText)); };
+
+ $.ajax(ajaxOptions);
function successFunc(d) {
$.extend(intermediateLangData, d);

0 comments on commit 132358e

Please sign in to comment.
Something went wrong with that request. Please try again.