shosho s

shosho s

  • NA
  • 137
  • 95.1k

How to return multiple values using json?

Feb 23 2016 7:15 AM
This is my script:
 
 
function UpdateFields() {
var StudentId = parseInt($('#@Html.IdFor(m => m.StudentId)').val());
var  ProjectId= parseInt($('#@Html.IdFor(m => m.ProjectId)').val());
var Par = {
'StudentId ': StudentId ,
'ProjectId': ProjectId
};
$.ajax({
url: '@Url.Action("New")',
data: Par,
type: 'GET',
success: function (data) {
$('#@Html.IdFor(m => m.StudentId )').val(data);
$('#@Html.IdFor(m => m.ProjectId)').val(data);
},
error: function (request, status, error) {alert('error');
});
 
 This is my action in my controller
 
public ActionResult New(StudentNewViewModel model)
{
model.LoadFromFields(SCPProvider, model.StudentId , model.ProjectId);
return Json(model.StudentId , JsonRequestBehavior.AllowGet);
}
 
My question is how can i return both  StudentId and ProjectId  with Json? so that these two fields  can be updated dynamically when changes on form are made.
 
 
 
 
 
 
 

Answers (3)