0

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
  • What do you have so far, and how doesn't it work? Commented Jan 22, 2010 at 13:42

1 Answer 1

1
$.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);
});
Sign up to request clarification or add additional context in comments.

2 Comments

I think you are missing the datatype setting too which need to setup correctly as 'json'.
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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.