How can I determine the appropriate parameter to use when passing a JavaScript object?
Please see below:
var all = [];
//iterate through each instrument
for (var i = 0; i < 3; i++) {
var txt = getThis(i);//int
var detail =getThat(i);//string
all.push({
'this': txt,
'that': detail
});
}
ajaxCall.getNow("myUrl", {
all
};
Here, ajaxCall.getNow
is simply invoking the standard $ajax with get
.
The main question is what kind of parameter should be used in my MVC controller.
If I use object
, it works but not sure how to handle the object. It becomes quite useless as an object.
When attempting tuple<in, string>
, it does not function.
For instance:
public JsonResult MyFunction(Tuple<int,string,string,double,double,string,int> all)//this fails
public JsonResult MyFunction(object all)//this works but I only have an ojbect, I@d like to have something like the tuple to work with
So, how do I determine the appropriate type of parameter for my MVC controller?