mardi 7 juillet 2015

How to send multiple JSON results from controller to view?

Here I am sending one item from controller to view. How can I send more than one item from controller to 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;


    }

Aucun commentaire:

Enregistrer un commentaire