Я пытаюсь заполнить параметры элемента select в родительском окне данными, возвращаемыми из вызова ajax, который вызывается из дочерней (всплывающей) формы.Дочерняя форма вызывается из родительского окна с помощью window.open.
Странно, что удаление опций выбора работает;это успешно выполняется:
$('#selElement', opener.document).find('option').remove().end();
Но добавление, как показано ниже, выдает SCRIPT5022: исключение выброшено и не перехвачено.
$('#selElement', opener.document).append($("<option />").val('').text('---Select---'));
Я также пробовал
$('#selElement', opener.window.document).append($("<option />").val('').text('---Select---'));
вот код:
// the line below works; it removes all of the options from the drop-down
$('#selElement', opener.document).find('option').remove().end();
// the ajax call below returns the right data
$.ajax({
url: 'actions.cfc?method=getOptions&returnFormat=json',
dataType: 'json',
// the value being sent here just limits the options returned in the results
data: {myType: $('#myType').val()},
async:false,
success: function(response) {
// getting the right data back
console.log(response);
// the line below results in SCRIPT5022: Exception thrown and not caught
$('#selElement', opener.document).append($("<option />").val('').text('---Select---'));
// never get this far unless I comment out the line above; then the error is thrown here
for (var i = 0; i < response.DATA.length; i++) {
$('#selElement', opener.document).append($("<option />").val(response.DATA[i][0]).text(response.DATA[i][1]));
}
},
error: function (response) {
var r = jQuery.parseJSON(response.responseText);
alert("Message: " + r.Message);
}
});
Есть идеи?