views:

181

answers:

1

Hi guys, Can someone help me with this? I hope so... Well, I'm struck for displaying that JSON array in a HTML list :

[{"foo":"30000","bar":"Nimes"},{"foo":"30100","bar":"Ales"},{"foo":"30110","bar":"Branoux Les Taillades"},{"foo":"30110","bar":"La Grand Combe"},{"foo":"30110","bar":"La Levade"},{"foo":"30110","bar":"Lamelouze"},{"foo":"30110","bar":"Laval Pradel"},{"foo":"30110","bar":"Les Salles Du Gardon"},{"foo":"30110","bar":"Soustelle"},{"foo":"30110","bar":"Ste Cecile D Andorge"},{"foo":"30111","bar":"Congenies"},{"foo":"30114","bar":"Boissieres"},{"foo":"30114","bar":"Nages Et Solorgues"},{"foo":"30120","bar":"Arphy"},{"foo":"30120","bar":"Arre"},{"foo":"30120","bar":"Aulas"},{"foo":"30120","bar":"Aveze"},{"foo":"30120","bar":"Bez Et Esparon"},{"foo":"30120","bar":"Breau Et Salagosse"},{"foo":"30120","bar":"Le Vigan"},{"foo":"30120","bar":"Mandagout"},{"foo":"30120","bar":"Mars"},{"foo":"30120","bar":"Molieres Cavaillac"},{"foo":"30120","bar":"Montdardier"},{"foo":"30120","bar":"Pommiers"},{"foo":"30120","bar":"Rogues"},{"foo":"30121","bar":"Mus"},{"foo":"30122","bar":"Les Plantiers"},{"foo":"30124","bar":"L'Estrechure"},{"foo":"30124","bar":"Peyroles"}]

The code to display the result is in rpc.php:

$.post("rpc.php", {queryString: ""+answer{$ia[1]}+""}, function(data){
  console.log(data.foo);
}); //fin $.post

Help, help, help thanks for reading!

+1  A: 
$.post("rpc.php", {queryString: ""+answer{$ia[1]}+""}, function(data){       
    var result = '';
    $.each(data,
          function() {
               result += '<li>Foo =' + this.foo + ' Bar =' + this.bar + '</li>';
          });
    $('#idofulyouwanttoshow').html(result);
});
Tony Miller
I think you are missing the datatype setting too which need to setup correctly as 'json'.
Teja Kantamneni
Thank you a lot Tony and Teja.You Tony lead the way, but Teja has made the last with the "add json datatype" tip.Un très grand merçi à vous tous!
knibals