Jquery Ajax Json çağırma (1 İzleyici)

Etkenblog

Üye
Katıldı
Mesajlar
99
Kredi
0
Jquery ile ajax çağrısı yolladığınızda dönüş JSOn olacaksa aşağıdaki şekilde alınlabilir.

Küçük bir örnek:

DOM tarafı:




$(document).ready(function(){
//attach a jQuery live event to the button
$('#getdata-button').live('click', function(){
$.getJSON('json-data.php', function(data) {
//alert(data); //uncomment this for debug
//alert (data.item1+" "+data.item2+" "+data.item3); //further debug
$('#showdata').html("<p>item1="+data.item1+" item2="+data.item2+" item3="+data.item3+"</p>");
});
});
});


örnek PHP tarafı



echo "{";
echo "item1: ", json_encode($item1), "\n";
echo "item2: ", json_encode($item2), "\n";
echo "item3: ", json_encode($item3), "\n";
echo "}";
 

Bu konuyı kimler okuyor

Benzer konular

Top