Search code examples
jsonajaxjsonp

How to get values of JSONP returned array


i'm getting data on local from cross domain.

$.ajax({
    type: "GET",
    url: "http://sunnah.com/ajax/urdu/bukhari/1?callback=items",
    dataType: 'jsonp',
    jsonpCallback: 'items',
    jsonp: 'callback',
    success: function (data) {
        var data = $.parseJSON(data)
        console.log(data);
    }
});

i can see returned json array like [{"urduURN":"4000010","collection":"bukhari"}....] that can be seen given URL. but i am unable to get anything in console.log(data) i wish also to put it's values to html element which is returning from data doing loop. please apprise me where i'm doing mistake?


Solution

  • Try this:
    $.ajax({
    type: "GET",
    url: "http://sunnah.com/ajax/urdu/bukhari/1?callback=items",
    dataType: 'jsonp',
    jsonpCallback: 'items',
    jsonp: 'callback',
    success: function (data) {
        var strData = JSON.stringify(data);
        console.log(strData );
    }
    });