3
I’m making a select
that will have some users and when selecting a user will send a request $.post
to get all records related to the selected user. After returning the related entries, the jQuery will return the callback
of $.post
and through the returned data I need to make a loop to add all the returned names within the <option></option>
, the problem is that I do not know how to do this. The data will be returned in json by PHP and jQuery have to capture by callback and form a loop to put in <option>
.
I know that to add a record to option
I use the code
$('#example').append('<option value="foo" selected="selected">Foo</option>');
But I wanted to know how to loop with the json returned by callback.