Ok. So I have two elements on a page which are not located in a single form. I need these to be posted back to my controller via the JQuery.Ajax() method. Now the problem I have is that while my parameters do correctly post they only do so if I set them as strings and they include the parameter name in the value. So:
Public ActionResult Method(String Age1, String Age2)
{
Age1=23; Age2=43
}
I get
Public ActionResult Method(String Age1, String Age2)
{
Age1="Age1=23"; Age2="Age2=43"
}
Which is irritating. Is there any way to make sure MVC will map the parameters correctly and only take in the correct values? I really want it to do:
Public ActionResult Method(Int32 Age1, Int32 Age2)
{
Age1="Age1=23"; Age2="Age2=43"
}
The jQuery call:
$.ajax{(
//other stuff
data: { Age1: $('.id').val(), Age2: $('.id2').val() };
)};
Opps, It was because in my actual code I was using Serialize! DUH!