javascript - Building an array for ajax? -


i need send array via ajax, reason not send, suspect due serialisation.

so how create array ajax compatible?

i need array in format, key value pair value array.

[order: array[1], type: array[1]] 

i declare array so:

filters = []; 

if inputs checked add them array.

var order = $('input[name="order[]"]:checked').map(function(){return this.value;}).get(); if(!$.isemptyobject(order))this.filters['order'] = order; .... 

with idea, if no inputs selected, array blank , therefore not sent ajax.

how can maintain structure of array make compatible ajax?

arrays don't use key-value pairs. instead, use object.

var obj = {order: array[1], type: array[1]} 

Comments