All of this is for discard a problem with a MVC controller.
This is the code of the ajax:
$.ajax({
//tipo de transferencia
type: "POST",
//dato a enviar
dataType: 'Json',
traditional:true,
//enviar variable previamente formada contiene la estructura del modelo
data:data,
//liga previamente asignada esta liga contiene la ruta controlador-metodo
url: url,
Notice the traditional:true.
jQuery API documentation
http://api.jquery.com/jQuery.Ajax/#jQuery-ajax-settings
traditional
Type: Boolean
Set this to true if you wish to use the traditional style of param serialization.
The traditional
property changes the way how parameters are sent to the server. As of jQuery 1.8, it is defaulted to false.
For ASP.NET MVC developer
$.ajax(url, {
data : { a : [1,2,3] },
traditional : true
}));
// `data` are sent as "a=1&a=2&a=3"
If traditional
was set to false
the data would be sent as a%5B%5D=1&a%5B%5D=2&a%5B%5D=3
Answer adapted from neverever from this thread
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With