All your web development code goes here

Archive for the ‘ajax’ Category

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&#8221;,
{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>”);
});
});

%d bloggers like this: