Remote JSON data problem

2 posts, 0 answers
  1. Greg
    Greg avatar
    2 posts
    Member since:
    Jul 2014

    Posted 24 Jul 2014 Link to this post

    I'm just trying to connect to my own website and get some JSON data and it always returns an error. If I change the dataType to "json" and make the url to an 

    identical local JSON file it works just fine. 

    What am I doing wrong here?
    $(document).on('pageinit', '#home2', function(){
        //var url = 'data/projList2.json';
        //var url = 'data/projList30.json';
            url: url,
            dataType: "jsonp",
            async: true,
            success: function (result) {
            error: function (request,error) {
                alert('Network error has occurred please try again!');

  2. Anton Dobrev
    Anton Dobrev avatar
    529 posts

    Posted 29 Jul 2014 Link to this post

    Hi Greg,

    As far as your web service returns JSON-formatted results you need to pass 'json' to the 'dataType' configuration option of the jQuery.ajax() object. Please note that in the success handler of the request there is no need to use ajax.parseJSON() as the result is already formatted as JSON.

    For using the 'jsonp' in the 'dataType' configuration option the server needs to know how to respond with accordingly formatted results, e.g. wrap the results in a callback function call that can be accessed by the client-side JavaScript.

    Please, let us know if you have further questions.

    Anton Dobrev

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

Back to Top