javascript - How to send multiple JSON results from controller to view? -
here sending 1 item controller view. how can send more 1 item controller view??
//controller public jsonresult getquantity(string id) { string getquantity = ""; string items="hello quantity" getquantity = items.tostring(cultureinfo.invariantculture); return json(getquantity, jsonrequestbehavior.allowget); } // view function getquantity(id) { var targetdiv = '#divyarndistributionviewer'; var url = "/stsm/stsa/yarndistribution/getquantity/" + id; var form = $("#frmyarndistributionviewer"); var serializedform = form.serialize(); $.post(url, serializedform, function (result) { $("#yarndistribution_stockquantity").val(result); }, "json"); return false; }
by of @jdupont , @kevin simple, have solved problem.
these guys.
public jsonresult getquantity(string id) { // here id not used, use quantity , unit project purpose. string getquantity = ""; string getunit = ""; string item1="hello quantity" string item2="hello unit" getquantity = item1.tostring(cultureinfo.invariantculture); getunit = item2.tostring(cultureinfo.invariantculture); return json(new { getquantity, getunit },jsonrequestbehavior.allowget); } // view function getquantity(id) { var targetdiv = '#divyarndistributionviewer'; var url = "/stsm/stsa/yarndistribution/getquantity/" + id; var form = $("#frmyarndistributionviewer"); var serializedform = form.serialize(); $.post(url, serializedform, function (result) { $("#yarndistribution_stockquantity").val(result.getquantity); $("#yarndistribution_stockunit").val(result.getunit ); }, "json"); return false; }
Comments
Post a Comment