我製作了數組$latent_weights_array
,我希望當按鈕'save'通過ajax運行一個php腳本時,通過$ _GET變量。通過Ajax通過json_encode獲得PHP數組
在031instsql.php
<?php
if (isset($_GET['latentweights'])){
echo $_GET['latentweights'];
$kati=array();
$kati=json_decode($_GET['latentweights'],true);
}
?>
1.爲什麼JavaScript的
function ajaxWeight(latentweights){
// trim code here
var queryString = "?latentweights=" + latentweights;
ajaxRequest.open("GET", "031instsql.php" +
queryString, true);
ajaxRequest.send(null);
}
<?php
echo "<input type='button' class='btn'
onclick='ajaxWeight(".json_encode($latent_weights_array).")' value='Save'/>";
?>
似乎不工作? 2.這裏需要做什麼?
你檢查你的錯誤控制檯? –
您可以使用Firebug或Chrome Developer工具來檢查您的ajax請求。 – brpaz
我的控制檯沒有錯誤 – Stam