title: MVC4: Is it possible with one Ajax call to controller from view to get back partial view as html and Json format data ?
body: <p>MVC4: is it possible with one Ajax call to controller action from script on razor view to get back partial view as html and Json format data ?
  Now I have two functions that make two trips to controller to two diff actions, each action calls same stored procedure to get data from db. I would like to combine it into one call.</p>
  
  <p>VIEW scripts section:</p>
  
  <pre><code>function getPartialViewHtml(){      
     var val1=1;
  
     $.ajax({
         type:"POST",
         url: 'Home/GetPartialViewHtml',
         data: { parm1 : val1 },
         success:  function(htmlResult){
            $('#divShowPartial').html(data);
            getJsonResult(val1);
         }
     });
  }
  
  function getJsonResult(val1)
  {
     $.ajax({
         type:"POST",
         url: 'Home/GetJsonResult',
         data: { parm1 : val1 },
         success:  function(jsonResult){
            $('#txtShowJsonData1').val(data.text1);  
            $('#txtShowJsonData2').val(data.text2);            
         }
     });
  }
  </code></pre>
  
  <p>CONTROLLER</p>
  
  <pre><code>public PartialViewResult GetPartialViewHtml(int parm1)
  {
     PartialViewModel model = new PartialViewModel(parm1);  // calls MyOtherModel model= new MyOtherModel (parm1); 
     return PartialView("MyPartialView", model);
  }
  
  public ActionResult GetJsonResult(intparm1)
  {
     MyOtherModel model= new MyOtherModel (parm1); 
     return Json(model);  
  }
  </code></pre>
  
  <p>MODELS</p>
  
  <pre><code>class PartialViewModel 
  {
     public MyModel mm {get; set;}
  
     public string otherData {get; set;}
     ........
  }
  
  class MyModel
  {
     public int id {get; set;}
     public string text1 {get; set;}
     public string text2 {get; set;}
  }
  </code></pre>