hurriedly% 2016-01-14 13:21 采纳率: 100%
浏览 26

通过ajax发送数组到php。

I'm storing an array and sending this via ajax...

var heart = [31,32,33,34,35,36,37,38,39,42,43];
// Sending this data via ajax to php file/ 
 $.ajax({
 type: "POST",
 data:{ 'system': heart }, 
 url: "login-function.php",
 success: function(msg){
 alert('yes');
}
});

I believe its sending correctly because i'm getting a alert saying yes. This is my php file:

$system = $_POST['system'];
echo $system;

Am I storing this into a variable right ? How can i echo this value onto the page?

  • 写回答

3条回答 默认 最新

  • H_MZ 2016-01-14 13:26
    关注

    you can use print_r( $system ); or use a foreach statement:

    foreach ( $system as $itm ) {
        echo $itm . '<br />';
    }
    

    edit: echoing in PHP is only available for strings, intergers etc; not arrays or objects.

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置