User-1952516322 posted
Hi,
I want to return Json object after form submit.
If I have below case:
@using (Html.BeginForm("Upload","Home",FormMethod.Post,new{id = "myForm", enctype = "multipart/form-data"}))
{
<input type="file" name="files" />
<input type="submit" />
}
public ActionResult Upload(IEnumerable<HttpPostedFileBase> files){
return Json(new
{
result = "success",
errors = "Fail"
}, JsonRequestBehavior.AllowGet);
}
// How can I read this object in View again or pass this json object as parameter to javascript function, Note: I did not call the action "Upload" by ajax.
ex:
$.ajax({
url: 'Url.Action("Upload","Home"),
data:... etc
success:function(data){
// If I do this way, I can read object. But I want to call function after submit completed.
// I tried attributes > onsubmit / AjaxOptions OnComplete ... but nothing work.
}
});
Any assist please.