我不得不在这里通过prototype ajax.request方法向PHP脚本发送一个数组。
我的数组是在javascript端构造的:如下所示
attributeArray = new Array();
//This line of code is actually inside a loop
attributeArray[id] = value;
//loop end
new Ajax.Request(reloadurl, {
method: 'post',
parameters: {'id[]':attributeArray},
onComplete: function(transport) {
$('load-map-fields').innerHTML = "";
$('load-map-fields').innerHTML = transport.responseText;
}
});在PHP脚本中,我得到了这个数组
Array ( [id] => Array ( [0] => special_price [1] => tier_price ) )请注意,值special_price和tier_price的索引号分别是0和1。这些不是我传递的实际索引,无论我构造什么索引,它都会从0重新索引它们。这对我来说没有用,因为我需要实际的索引id和值。
发布于 2012-08-13 22:00:29
你应该使用散列而不是数组。喜欢
attributeArray = {}https://stackoverflow.com/questions/11935815
复制相似问题