1

Can u help me to how to get the json data in controller.

 $.ajax({
    type: 'Post',
    url: 'getdata',
    dataType: 'json',
    data: JSON.stringify(value), //value is an array
    contentType: 'application/json',
    success: function (data) {                    
    },
    error: function (xhr, textStatus, errorThrown) { 
    }
});

Controller:

public ActionResult getdata()
{
   view()
}

I dont have any idea about the controller or model .Suggest some ideas

SBI
  • 2,322
  • 1
  • 17
  • 17
Jenu
  • 23
  • 1
  • 5

1 Answers1

0

Jenu,

You'll need to have a parameter of the type that matches your json model along the lines of:

your model may look like:

public class MyModel{
    public string FirstName {get; set;}
    public string LastName{get; set;)
    public bool IsHappy {get; set;}
    // etc. etc
}

public ActionResult GetData(MyModel data)
{
   // do what you need with the data here
   return View();
}

This question is so braod that I think you'd be best to google up some searches for 'json model asp.net mvc' and take it from there. I'll add a few links later.

[edit] - as promised, a few links:

THe final link in the list above almost gives a perfect blow by blow account of what you need to do. I suggest you study that well. good luck.

Community
  • 1
  • 1
jim tollan
  • 22,305
  • 4
  • 49
  • 63
  • I already google up and didnt get clear understanding . can u help me to declare in model – Jenu Nov 27 '13 at 08:36
  • see edit... tho it will depend on what your model properties are. rough attempt to show generis type teaser – jim tollan Nov 27 '13 at 08:37