I have an issue when sending to server array in POST via ajax with JQuery version is 1.10.2. My array is array of objects (such object is basically an associative array).
Function JSON.stringify(word_mean_arr); return [[]] - so it fail to work and if I simply write:
$.post( "./ajax2/myscript.php", {block_id: bl_id, wm_arr: word_mean_arr})
I cannot get value of $POST['wm_arr'] like it does not exist.
Example of my array is something like:
[[key]=>1,[value]=>"this_is_"],[[key]=>2,[value]=>"this_is_str2"]
So my object is:
[ [key]=>1, [value]=>"this_is_str"]
This is how I form my array
var word_mean_arr = new Array();
for (var i = 0; i <= this.n_of_wd_mean; i++)
{
var temp_arr = new Array();
temp_arr['key'] = $("#tswes_2_"+i).val();
temp_arr['value'] = $("#tswes_2_"+i).val();
word_mean_arr.push(temp_arr);
}
console.log("Array to server length>" + word_mean_arr.length);
var jsonString = JSON.stringify(word_mean_arr);
How should I transfer data and what is the problem?
UPDATE 1: JSON.stringify(temp_arr) is [], but when console.log(word_mean_arr) I see whole structure of my array.
UPDATE 2: Replacing temp_arr['key'] with temp_arr[0], solves my problem. But still qurious how to send key->val.