I am trying to GET jSON data from external link using AJAX and for reason its not printing the output. I tried looking into many questions and tried in the following ways and none worked for me.
Test 1
$.ajax({
"url":"http://20percents.com/created_by_mohan/testAll.php",
"type":"GET",
"data": { fields: "title" },
"dataType":"jsonp",
"contentType":"application/json",
"jsonpCallback":"myCallback",
"success":function(data){
console.log(data);
alert(data.title);
}
})
Test 2
$.ajax({
url: 'http://20percents.com/created_by_mohan/testAll.php',
type: 'GET',
data: { fields: "title" },
success: function(data) {
//called when successful
$('body').html(data);
},
error: function(e) {
}
});
Test 3
var mydata;
$.ajax({
url: 'http://20percents.com/created_by_mohan/testAll.php',
dataType: 'json',
success: function(data) {
mydata = data;
console.log(mydata);
}
});
Test 4
$.ajax({
type:"GET",
url: "http://20percents.com/created_by_mohan/testAll.php",
success: function(data) {
$("body").append(JSON.stringify(data));
},
error: function(jqXHR, textStatus, errorThrown) {
alert(jqXHR.status);
},
dataType: "jsonp"
});
I need to get some data for instance title, storeid, store-cuisines for now. How can I make this working?
Thanks
consoleof the browser. Usually such errors will be shown there.