dongluanban3536 2013-09-11 00:46
浏览 24
已采纳

对php脚本进行Ajax POST查询

so I have 9 check boxes which I want to post the data of to my php script and am stuck as to how I would do this? I have found this base:

$.ajax({
  type: "POST",
  url: "check.php",
  data: data,
  success: success,
  dataType: dataType
});

But I don't know how to go about setting that data, success and dataType of that function. I want to be able to send the states/values of my 9 checkboxes as the data and want to be able to call a javascript function which is parsing the output of the post request. This is what my check boxes look like.

<form id="myform">
    <input type="checkbox" id="1" name="1"/>
        <label for="1"><span>1</span></label>
    <input type="checkbox" id="2" name="2"/>
        <label for="2"><span>2</span></label>
    <input type="checkbox" id="3" name="3"/>
        <label for="3"><span>3</span></label>
    <input type="checkbox" id="4" name="4"/>
        <label for="4"><span>4</span></label>
    <input type="checkbox" id="5" name="5"/>
        <label for="5"><span>5</span></label>
    <input type="checkbox" id="6" name="6"/>
        <label for="6"><span>6</span></label>
    <input type="checkbox" id="7" name="7"/>
        <label for="7"><span>7</span></label>
    <input type="checkbox" id="8" name="8"/>
        <label for="8"><span>8</span></label>
    <input type="checkbox" id="9" name="9"/>
        <label for="9"><span>9</span></label>
</form>

Thanks.

  • 写回答

1条回答 默认 最新

  • dswsl2016 2013-09-11 00:48
    关注

    if the data is in a form you can serialize the form

    var data = $('form').serialize();
    

    see http://docs.jquery.com/Ajax/serialize

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路