I'm quite new to ajax, I'm not able to solve this problem and I can't find other topics discussing about it.
What I have to do is send with ajax an array to a php script.
The array is an associative array [index][value]. The problem is that, once I've sent the array to php, it seems like a monodimensional array.
In other words, an example:
if the array is: ["apple", "pear", "orange"]
should be: array[0] prints "apple"
BUT in php the array consists in only one element, which is the concatenation of all the strings. So if I print array[1] I'll obtain "p", array[4] "e", etc.
How can I fix it?
Thank you in advance for your help.
var items = new Array();
CODE AJAX SCRIPT:
$.ajax({
type: "POST",
url: "calculate.php",
data: "items=" + items,
dataType: "html",
success: function(msg)
{
var response = jQuery.parseJSON(msg);
$('#second_results').html(response.output);
},
error: function()
{
alert("Failed");
}
});
PHP:
$items = $_REQUEST["items"];