【发布时间】:2013-06-23 10:37:56
【问题描述】:
我已经创建了数组$latent_weights_array,我希望当我按下“保存”按钮以通过 ajax 运行 php 脚本时,将 are 作为 $_GET 变量传递。
在 PHP 中
<?php
echo "<input type='button' class='btn'
onclick='ajaxWeight(".json_encode($latent_weights_array).")' value='Save'/>";
?>
在javascript中
function ajaxWeight(latentweights){
// trim code here
var queryString = "?latentweights=" + latentweights;
ajaxRequest.open("GET", "031instsql.php" +
queryString, true);
ajaxRequest.send(null);
}
在 031instsql.php 中
<?php
if (isset($_GET['latentweights'])){
echo $_GET['latentweights'];
$kati=array();
$kati=json_decode($_GET['latentweights'],true);
}
?>
1.为什么似乎不起作用? 2.这里需要做什么?
【问题讨论】:
-
您检查过控制台是否有错误吗?
-
您可以使用 Firebug 或 Chrome 开发者工具检查您的 ajax 请求。
-
我的控制台没有错误
标签: php jquery ajax arrays json