douzhengyi5022 2011-01-24 20:40
浏览 29
已采纳

使用Ajax和jQuery动态发送多个值

  • I have an unknown amount of clickable buttons. (generated)
  • Every button is connected to multiple values that should be sent through the Ajax call.

I found this to start with:

$.ajax({
    type: "POST",
    url: "some.php",
    data: parameters,
    success: function(msg){
    alert("nothing");
}
});

data contains parameters as far as I know. My parameters are different depending on what button that is clicked.

My guess is that I could use this somewhere? But what if I need to send 3 values?

<input type="button" id="unique-1"> <!-- With values 'test', 3 and 5 -->
<input type="button" id="unique-2"> <!-- With values 'doh2', 8 and 6 -->

I use PHP if you need that info.

Thanks!

  • 写回答

2条回答 默认 最新

  • duanmie9682 2011-01-24 20:51
    关注

    Check out this fiddle. The button will find the form that it needs to submit, serialize the data, and alert that string. You would just need to then use that string as the parameter for the data option of the ajax call.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器