0
入力に何も表示されません。選択にデータが表示されません
これが私の見解で私のスクリプト機能である:私はデータを表示したい
<script>
var Caracteristicas = [];
function LoadCaracteristicas(element) {
if(Caracteristicas.length === 0)
{
$.ajax({
url:'@Url.Action("GetCaracteristicas","Inspeccion")',
type: 'GET',
cache: false,
dataType: 'json',
success: function(data){
Caracteristicas = data;
alert(data);
renderCaracteristica(element)
},
error: function (e) {
console.log(e)
}
});
}
else
{
renderCaracteristica(element);
}
}
function renderCaracteristica(element) {
var $ele = $(element);
$ele.empty();
$ele.append($('<option/>').val('0').text('Select'));
$.each(Caracteristicas, function (i, val) {
$ele.append($('<option/>').val(val.Id_Caracteristica).text(val.Descripcion));
})
}
マイセレクト:
<table class="table table-responsive">
<tr>
<td>Caracteristica</td>
<td>Resultado</td>
<td> </td>
</tr>
<tr class="mycontainer" id="mainrowCateristica">
<td>
<select id="IDCateristicas" class="form-control"> ----- Show Data
<option>Select</option>
</select>
<span class="error">Seleccione una Caracteristica</span>
</td>
<td>
<input type="radio" id="RadioOK" name="resultado" value="1"> OK<br>
<input type="radio" id="RadioNOK" name="resultado" value="0"> NOK<br>
</td>
<td>
<input type="button" id="BtnAdd" value="Agregar" style="width:80px" class="btn btn-success" />
</td>
</tr>
</table>
私のコントローラ機能:
public JsonResult GetCaracteristicas()
{
CalidadEntities db = new CalidadEntities();
var data = from c in db.Caracteristicas select c;
return Json(data.ToList(), JsonRequestBehavior.AllowGet);
}
Th電子コントローラは、関数JsonResultでデータを渡すと仮定しますが、selectではanythibgを表示しません。初めに私の見解では
:
<script type="text/javascript">
window.onload = function() {
LoadCaracteristicas($("#IDCateristicas"));
};
「アラート(データ)」には何が表示されますか? – adeneo
GetCaracteristicas()関数は任意の値を返しますか? from C# –
'LoadCaracteristicas()'を呼び出す場所が見つかりませんでした。この電話がありますか? –