How Do I Consuming Rest Service With Jquery In Phonegap
I am using monaca IDE + phonegap to build a phone app. I have created a restful server - http://engridmedia.com/next/api/channel/user/id/1 And i am trying to consume the json res
Solution 1:
Try this:
$(document).ready(function() {
$.ajax({
cache: false,
url: "http://engridmedia.com/next/api/channel/user/id/1",
type: 'GET',
crossDomain: true,
dataType: 'json',
success: function() {
alert("Success");
},
error: function() {
alert('Failed!');
},
}).then(function(data) {
var result = data [0];
console.log(result)
$('.ch-name').append(result.ch_name);
$('.ch-logo').append(result.ch_logo);
});
});
You are returning a object in a array. You need to get the first object in that array.
Post a Comment for "How Do I Consuming Rest Service With Jquery In Phonegap"