All of this is for discard a problem with a MVC controller.
所有这一切都是为了放弃一个MVC控制器的问题。
This is the code of the ajax:
这是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.
注意到传统:没错。
1 个解决方案
#1
2
jQuery API documentation
jQuery API文档
http://api.jquery.com/jQuery.Ajax/#jQuery-ajax-settings
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.
如果您希望使用param序列化的传统样式,请将其设置为true。
The traditional
property changes the way how parameters are sent to the server. As of jQuery 1.8, it is defaulted to false.
传统属性改变了向服务器发送参数的方式。在jQuery 1.8中,默认为false。
For ASP.NET MVC developer
ASP。净MVC开发人员
$.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
如果传统设置为false,则数据将以%5B%5D=1&a%5B%5D=2&a%5B%5D=3的形式发送
Answer adapted from neverever from this thread
答案改编自永不言传
#1
2
jQuery API documentation
jQuery API文档
http://api.jquery.com/jQuery.Ajax/#jQuery-ajax-settings
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.
如果您希望使用param序列化的传统样式,请将其设置为true。
The traditional
property changes the way how parameters are sent to the server. As of jQuery 1.8, it is defaulted to false.
传统属性改变了向服务器发送参数的方式。在jQuery 1.8中,默认为false。
For ASP.NET MVC developer
ASP。净MVC开发人员
$.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
如果传统设置为false,则数据将以%5B%5D=1&a%5B%5D=2&a%5B%5D=3的形式发送
Answer adapted from neverever from this thread
答案改编自永不言传