Send Model to Controller using JQUERY AJAX Call

For ASP.NET MVC Developer, there is main problem to send model to controller using AJAX Call


Let’s send model without form post method using AJAX

Partial View

@using(Html.BeginForm(“ActionMethodName”,”ControllerName”,FormMethod.Post,new{ @id=”form1”}))
{
 // Partial View Details here
}



Jquery Method


function Insert()
{
  Var model=$(‘#form1’).serialize();
// Serialize model for Posting model 
$.ajax({
url: @Url.ActionLink(‘MethodName’,’ControllerName’,new{ Area=”AreaName”}),
type=’POST’,
data: model,  // Pass Model to Controller Using Ajax Call
success:function(data)
{
// Show Data
}
});  
}

Comments

  1. url: @Url.ActionLink(‘MethodName’,’ControllerName’,new{ Area=”AreaName”}),
    wht stand for third parameter ,new{ Area=”AreaName”} and how it is consumed further in action

    ReplyDelete
    Replies
    1. Third Parameter stands for area section . if your controller exists in area then you have to specify area name.

      This will direct hit to that area then hit controller of that area which u have specified in url...

      Delete
  2. The new alternative uses the Web based variation from the MVC pattern while the 2.0 version works on both, Visual Studio 2008/.Net 3.5 and the Visual Studio 2010 /.Net 4.

    Hire ASP.Net MVC developer in India

    ReplyDelete
  3. It is explained in clear way. It is very easy to understand the information.

    Best Microsoft Training in Bangalore for Microsoft, we provide the Microsoft training project with trainers having more than 5 Years of Microsoft training experience, we also provide 100% placement support.

    ReplyDelete

Post a Comment