My problem is that I can not change the value of my dropdownlist according to the value of one of the indexes that my ajax call returns to me.
Call ajax:
var idTets = $('select[id$=DdlTest]').val();
$.ajax({
type: "POST",
url: "xxxclase/xxxmetodo",
data: '{idTest:"' + idTets + '"}',
contentType: 'application/json; charset=utf-8',
dataType: "json",
success: function (result) {
$("input[id$=textWorkName]").val(result.d[0]);
$("textArea[id$=textWorkTopic]").val(result.d[1]);
if (result.d[2] == "Exam") {
$("#MainContent_dropType option[value=0]").attr('selected', 'selected');
//$("#MainContent_dropType").val(0);
} else {
$("#MainContent_dropType option[value=1]").attr('selected', 'selected');
//$("#MainContent_dropType").val(1);
}
if (result.d[3] == "True") {
$("input[type=checkbox]").addClass('checked', true);
}
//$("#MainContent_HfOnlineTestId").val(idTets);
//setTimeout(eventClick, 1000);
return;
},
error: function (xhr, status, error) {
alert(error);
}
});
I already tried it in those two ways but not an official and in fact I tried it with pure js through a for and it did not work either, the weird thing is that if I put it in a document.ready there if I change the value .
Result of the result result: