发送var数组从html到php的最佳方式是什么? 我尝试过使用serialise
,但它似乎没有正常工作。 感谢如何发送var数组从html到php
//HTML
var arrayTextAreasNames = ['1','2','3'];
xhttp.open("GET", "MyPhpScript.php?hId=" + inputId + "&arrayTextAreasNames=" + serialize(arrayTextAreasNames), true);
//Note: along with the array I am also sending another variable called inputId
//PHP
$arrayTextAreasNames = unserialize($_GET["arrayTextAreasNames"]);
console.log($arrayTextAreasNames); //The array is not read properly in php (empty!)
如何POST方法解码JSON纽约。在PHP中使用'print_r($ array)'或'var_dump($ array)'而不是'console.log' –
'console.log'不能在php中工作。它用于javasctipt – Saty