- Screen name: b1naryj
b1naryj's Profile
1 Posts
6 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
Background: Using ASP.NET MVC if you post to an action using the same variable names as those on the method signature it automatically parses them for you.
However with jQuery 1.4 if you post an ARRAY it changed how the post variable name is formed, adding [] to the end. This is an impasse since I obviously cannot append [] to my variable name in the controller.
At the moment this is a huge problem if we intend to upgrade to v1.4... ever.
jQuery 1.3.2 post data:
{myarrayvar=something&myarrayvar=somethingelse&anothervar=true}jQuery 1.4 post data:
{myarrayvar%5b%5d=something&myarrayvar%5b%5d=somethingelse&anothervar=true}Note the %5b%5d => []
Here's an example:
$.ajax({
type: "POST",
url: "/Home/Index",
data: { myarrayvar: ["something", "somethingelse"], anothervar: true},
...etcpublic ActionResult Index(string[] myarrayvar, bool anothervar) {
jQuery 1.3.2:
myarrayvar.Length == 2jQuery 1.4:
myarrayvar == null !Which makes sense since the variable name is no longer "myarrayvar", it is now "myarrayvar[]".
}
- «Prev
- Next »
Moderate user : b1naryj



