Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对php脚本进行Ajax POST查询_Php_Javascript_Jquery_Ajax - Fatal编程技术网

对php脚本进行Ajax POST查询

对php脚本进行Ajax POST查询,php,javascript,jquery,ajax,Php,Javascript,Jquery,Ajax,因此,我有9个复选框,我想将的数据发布到我的php脚本中,我一直在想我该怎么做?我找到了这个基础: $.ajax({ type: "POST", url: "check.php", data: data, success: success, dataType: dataType }); 但我不知道如何设置该函数的数据、成功和数据类型。我希望能够将9个复选框的状态/值作为数据发送,并希望能够调用一个javascript函数来解析post请求的输出。这就是我的复选框的外观 &l

因此,我有9个复选框,我想将的数据发布到我的php脚本中,我一直在想我该怎么做?我找到了这个基础:

$.ajax({
  type: "POST",
  url: "check.php",
  data: data,
  success: success,
  dataType: dataType
});
但我不知道如何设置该函数的数据、成功和数据类型。我希望能够将9个复选框的状态/值作为数据发送,并希望能够调用一个javascript函数来解析post请求的输出。这就是我的复选框的外观

<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>

1.
2.
3.
4.
5.
6.
7.
8.
9

谢谢。

如果数据是表单,您可以序列化表单

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

请参见

另外,数据必须是对象:
var data={valueA:inputA.val(),valueB:inputB.val(),[…])我现在唯一需要回答的问题是如何设置成功部分。成功必须是一个函数
success:function(response){/*如何处理响应*/}
请将此问题标记为已回答。@DuncanPalmer很乐意提供帮助