What is the best way to passing jquery values into php as a array?

2013 年 7 月 24 日3200

var $keywords = $("#mytags").siblings(".tagsinput").children(".tag");







var tags = [];



for (var i = $keywords.length; i--;) {



tags.push($($keywords[i]).text().substring(0, $($keywords[i]).text().length - 1).trim());



}



var tagsList = tags.toSource();



var data = {



dataType: 'json',



action: 'my_action',



whatever: tagsList // We pass php values differently!



};



jQuery.post(ajax_object.ajax_url, data, function(response) {



alert('Got this from the server: ' + response);



});



So I want to send the data I have into php as an array, my question is it better to send it into php as an array, how I would do this or is it better to just change it into an array in php after I sent so I can iterate through it? Also is it better to use .toSource() or .val() for changing it into a array?

**

I guess this might be more of a php ajax question but how do you pass a jquery value into php as an array so that it can be iterated through in php?

0 0