Results 1 to 3 of 3

Thread: Loading local json

  1. #1
    Sencha User
    Join Date
    Aug 2009
    Posts
    96

    Default Loading local json

    I have a json file in my www folder. I am trying to load it using ajax request:

    Code:
    Ext.Ajax.request({
      url: "file1.json",
      success: function(response, opts) {
        console.log("success");
      }, this),
      failure: function(response, opts) {
        console.log("fail");
      }
    })
    I am using PhoneGap 1.4.1. This works on Android. But fails on iPhone. Does anyone what the correct url should be for loading a local json file?

    I am not including it in a script tag in my index.html, because there could be many. I want to load them on demand.

  2. #2
    Sencha Premium Member
    Join Date
    Oct 2009
    Posts
    112

    Default

    looks like it failed because status is 0, but response.responseText contains the correct data.

    Searched internet. It seems to be a bug in phonegap, http://stackoverflow.com/questions/7...essful-request

  3. #3
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Loading against the file system will always have a status of 0 which isn't supported. To get a status like 200 you need to load via a web server.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •