title: Retrieve model with JavaScript
body: <p>I am returning data to the model and then I recover it with JS but I see that they come in Null, I add my code where I recover the data and where I send it</p>
  
  <p>C#</p>
  
  <pre><code>[HttpPost]
      public JsonResult AjaxMethod(string type, int value)
      {
          CascadingModelGastos model = new CascadingModelGastos();
          switch (type)
          {
              case "ProyectoID":
                  model.Recurso = PopulateDropDown("SELECT Id, Descripcion FROM [dbo].[Cat_Cuenta_Recurso] ", "Descripcion", "Id");
                  break;
              case "RecursoID":
                  model.SubRecurso = PopulateDropDown("SELECT Id, DescripcionSubRecurso FROM [dbo].[Cat_Cuenta_SubRecurso] WHERE Id_Cuenta_Recurso = " + value, "DescripcionSubRecurso", "Id");
                  break;
              case "SubRecursoID":
                  model.TipoPago = PopulateDropDown("SELECT ID, DescripcionTipoPago FROM[dbo].[Cat_TipoPago] WHERE ESTATUS = 'A'", "DescripcionTipoPago", "Id");
                  DataSet Tabla = new DataSet();
                  Tabla = BLL.BLL.Negocio.ConaultaImporte(value);
                  model.Programado = "$" + Tabla.Tables[0].Rows[0]["TotalProgramadoMensual"].ToString();
                  break;
          }
          return Json(model);
      }
  </code></pre>
  
  <p>The data that returns in null is: 
  <code>model.Programado = "$" + Tabla.Tables[0].Rows[0]["TotalProgramadoMensual"].ToString();</code></p>
  
  <p>So I invoke the method:</p>
  
  <pre><code>$("select").change(function () {
  
          var value = 0;
          if ($(this).val() != "") {
              value = $(this).val();
          }
          var id = $(this).attr("id");
          $.ajax({
              type: "POST",
              url: "../AjaxMethod",
              data: '{type: "' + id + '", value: ' + value + '}',
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function (response) {
                  var dropDownId;
                  var list;
                  switch (id) {
                      case "ProyectoID":
                          list = response.Recurso;
                          DisableDropDown("#RecursoID");
                          DisableDropDown("#SubRecursoID");
                          PopulateDropDown("#RecursoID", list);
  
                          break;
                      case "RecursoID":
                          dropDownId = "#SubRecursoID";
                          list = response.SubRecurso;
                          DisableDropDown("#SubRecursoID");
                          PopulateDropDown("#SubRecursoID", list);
  
                          break;
                      case "SubRecursoID":
                          dropDownId = "#TipoPagoID";
                          list = response.TipoPago;
                          DisableDropDown("#TipoPagoID");
                          PopulateDropDown("#TipoPagoID", list);
                          break;
                  }
  
              },
              failure: function (response) {
                  alert(response.responseText);
              },
              error: function (response) {
                  alert(response.responseText);
              }
          });
          var models = @Html.Raw(Json.Encode(Model));
          document.getElementById("Programado").value = models.Programado;
      });
  });
  </code></pre>
  
  <p>So I try to recover my model data:
  <code>var models = @Html.Raw(Json.Encode(Model));</code></p>
  
  <p>The final question is: At what time can I recover my model data???</p>