add

Wednesday, December 12, 2012

Simple Jquery Ajax and getjson call

get some Json Data through a remote API
$(document).ready(function(){
$.ajax({
type: "GET",
url: 'http://ecarobar.com/xyz/api.php',
data: { method: "get", name: "jab", format: "json" },
async: false,
dataType: "json",
beforeSend: function(x) {alert('Not Yet Sent')},
success: function(data){
alert ("AjAx Call"+data.responseBody.id+" "+data.responseBody.views); //further debug
$('#showdata').html("<p>item1="+data.responseBody.id+" item2="+data.responseBody.views+" </p>");
}
});

$.getJSON(
"http://ecarobar.com/xyz/api.php",
{method: "get", name: "jab", format: "json" },
function(data) {
//alert("JSON Data: " + json.users[3].name);
alert ("JSON Call"+data.responseBody.id+" "+data.responseBody.views); //further debug
$('#showdata').html("<p>item1="+data.responseBody.id+" item2="+data.responseBody.views+" </p>");
});
});

No comments:

Post a Comment