I just wrote this this morning. It does the same thing but is written slightly different, but is proven to work rock solid for me. In this case I used a named / value pair to bring back productID' and Part Numbers.
I use to use something more complex like your example but simplified it over time.
I stopped using each to loop the array, I'm sure some will say that each is more efficient and faster.
I stopped using html to create the option element as well, and just use javascript to create the tag.
I url encode string value from the server, and unescape them for decoding.
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "templateEditor.asmx/load_productSKUs",
data: '{ "p_categoryID": -1}',
dataType: "json",
error: function (xhr, status, error) {
var exitCode = 2;
alert(xhr.responseText);
},
success: function (responseText) {
var objB = jQuery.parseJSON(responseText.d);
var exitCode = objB.exitCode;
var productCount = objB.productCount;
var productArray = objB.productArray;
if (0 !== exitCode) {
}
else {
$('#cke_105_select').empty();
var option_s = document.createElement('option');
option_s.innerHTML = '-- Select a Part Number --';
option_s.value = '-1';
$('#cke_105_select').append(option_s);
var name, value, option;
for (var pdx = 0; pdx < productArray.length; pdx++) {
name = unescape(productArray[pdx].name.replace(/\+/g, " "));
value = productArray[pdx].value;
option = document.createElement('option');
option.innerHTML = name;
option.value = value;
$('#cke_105_select').append(option);
}
}
}
});
And the JSON
{
"exitCode": 0,
"productCount": 236,
"productArray": [
{
"name": "03-12E",
"value": 33
},
{
"name": "03-12EX",
"value": 270
}
]
}