简体   繁体   中英

JQuery Not working Cordova 3.1.0 on actual IOS device but works on emulator

I've been working on this for a long time now and banging my head for the solution for the problem.

I am working with cordova (phonegap) 3.1.0 using the IOS platform. I initially develop an app using the xcode iphone emulator and it works fine. Unfortunately, when I tried to run my app on the ipad the jquery that suppose to trigger the generation of json is not working.

I tried to include the following code but still there is no luck...

$.support.cors = true; 
$.mobile.allowCrossDomainPages = true;

I currently working with jquery mobile-1.3.2.js

here is the header of my index.html file

 <script type="text/javascript" src="cordova.js"></script> 
 <script> document.addEventListener("deviceready", onDeviceReady, false); function hyperlink(){ window.location = "introduction.html"; } </script> <link rel="stylesheet" type="text/css" href="css/index.css" /> <link rel="stylesheet" href="css/themes/default/jquery.mobile-1.3.2.css"> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.mobile-1.3.2.js"></script> 

and here is my jquery code:

$.getJSON(res/json/jsonFile.json, function(data){
    var md5ModName = null;
        for (var property in data) {
        if (data.hasOwnProperty(property)) {
            md5ModName = property;
        }
     }
  localStorage['mainJSON'] = JSON.stringify(data[md5ModName]);
});

your help will be appreciated :D

I found the solution for this problem... It turns out to be IOS cordova is very sensitive on the character case of file names.

I was importing

res/json/jsonFile.json

which the actual file is jsonFIle.json with a capital I.

Anyway, thanks Sirikon for your help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM