jquery - Json data - Undefined -
i seek json result controller action.
in view have ajax.actionlink
@ajax.actionlink("aggiungi riga", "step2", new ajaxoptions { url = url.action("ritornarighejson"), onsuccess = "processdata" })
into controller have
public jsonresult ritornarighejson() { rigafattura info = new rigafattura(); data.descrizione = "json"; data.nriga = 1; homecoming json(data, jsonrequestbehavior.allowget); }
that produce json object . test action ritornarighejson , see right output.
now problem onsuccess = "processdata". view have javascript class
<script type="text/javascript"> function processdata(data) { alert(data) var = data[0]; alert(a); } </script>
but value of info "undefined"
i solved. problem controller. alter into
public jsonresult ritornarighejson() { rigafattura[] elenco = {new rigafattura{nriga = 1,descrizione="prova riga"}}; ienumerable<rigafattura> info = elenco; homecoming json(data, jsonrequestbehavior.allowget); }
jquery json asp.net-mvc-5
No comments:
Post a Comment