Yeah, I have 3 or 4 different answers on the same subject but I'm struggling to combine them to create what I need. I serialize my results using Json.Net which results in the following object:
"[ { "Id": 1, "OrderInList": 1 },
{ "Id": 2, "OrderInList": 2 },
{ "Id": 4, "OrderInList": 3 }
]"
I'd like the option value and text to be the OrderInList value (I'll use the Id with something else later).
I've currently got the following code, but it creates 143 option boxes. I can see why it's doing it, but I'm not sure how to alter it to get it to work.
$.getJSON("/Json/GetOrderSelectList?parentCategoryId=" + postData, null, function (jsonResult) {
$('#orderInList').attr('enabled', 'true');
$.each(jsonResult, function() {
$.each(this, function(index, item) {
$('#orderInList').append(
$("<option></option>")
.text(index)
.val(index)
);
});
});
Any help would be appreciated!