Can you assist with correctly calling the loadlist
function using this JSON data below?
I have attempted to call it as shown but it appears to not be functioning properly:
loadlist($('select#selName').get(0), 'pull.php','data.name')
This is the JSON data in question:
{
data: [
{
id: "e0b0d8sc5ffd82e",
name: "John",
}
]
}
Below is the implementation of the function:
function loadlist(selobj,url,nameattr) {
$(selobj).empty();
$.getJSON(url,{},function(data)
{
$(selobj).append(
$('<option>Select</option>')
.val('null')
);
$.each(data, function(i,obj)
{
$(selobj).append(
$('<option></option>')
.val(obj[nameattr])
.html(obj[nameattr]));
});
});
}