user1217901
user1217901

Reputation: 31

Ajax sending multiple values

Normally Ajax syntax is

ajax('fn_name'['filter_value'],'target')

But I am using 3 filters in my page and so wanted to send all 3 values to ajax call.

ajax('fn_name'['filter1','filter2','filter3'],'target')

Is above syntax correct? Its not working.... Thanks in advance!

Upvotes: 0

Views: 119

Answers (1)

jrthib
jrthib

Reputation: 1319

To send these multiple values, i would serialize that array into JSON then process the JSON data in whatever backend is receiving it.

var filterArray = { 'fn_name': ['filter1', 'filter2', 'filter3'] };

ajax(JSON.stringify(filterArray));

Convert object string to JSON

Upvotes: 2

Related Questions