0

I am trying to parse json file in my phonegap application. after searching on Stackoverflow I found this code

here is my code

  $.getJSON('http://shobingg.com/cms/sites/php/message.json',
  function(data)
  {    
      $.each(data, function(i, item) {
          alert (item.message);
      });
      //$("#div-my-table").append("</table>");
  });

you can see the original post from here

what is the problem with my code?

6
  • Is http://shobingg.com/cms/sites/php/message.json returning a an array? Commented May 11, 2013 at 5:35
  • 4
    your cross domain request will be blocked check the firebug console Commented May 11, 2013 at 5:37
  • 1
    Cross domain shouldnt be an issue with Phonegap. Commented May 11, 2013 at 5:41
  • docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html Commented May 11, 2013 at 5:42
  • @Adam, the remote site (shobbing.com) should allow this request from a different origin isn't it? Commented May 11, 2013 at 5:58

1 Answer 1

0

Try this:

$(document).ready(function() {
    var url =  "http://www.shobingg.com/cms/sites/php/message.json";
    $.getJSON(url + "?callback=?", null, function(data) {
        console.log(data);
    });
});

Refered from jsonp with jquery

Sign up to request clarification or add additional context in comments.

1 Comment

your code is not working .. all I want is to alert the message from the json file check the link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.