When using jquery ajax with data containing an array, getting the parameter name with [] at the end

$.ajax({
            url:"SomeURL",
            data: {                
                fields : ["field1", "field2"],                
            },
            success: function(data) {
            }
});

How to do it on the server:

name = fields[] , VALUE = field1
name = fields[] , VALUE = field2

(note the brackets)

This is mistake? (This will start after upgrading to 1.5)

Thanx

+5
source share
1 answer

This is not a mistake, serialization has changed (but already in jQuery 1.4). Check out the option traditional:

traditional Boolean
Set this parameter trueif you want to use the traditional style of parametric serialization .

And from jQuery.param()(also look at an example):

jQuery 1.4, $.param() , PHP Ruby on Rails. , jQuery.ajaxSettings.traditional = true;.

+7

All Articles