我正在尝试创建一组复选框,我可以检查并通过 ajax 发送。
理想情况下,我希望通过 ajax 将几条信息发送到 php 脚本,the checkbox that has been checked
以及id
它id
基于 URL,所以我可以使用$_GET['id']
.
因此,如果用户选中了这两个框,则需要发送到 php 脚本的值将是:
53
57
1
- 此值是 URL 中的值。
到目前为止,我有以下内容:
<input type="checkbox" name="test[]" value="53" id="part_shipping" />
<input type="checkbox" name="test[]" value="57" id="part_shipping" />
<input name="confirm" type="button" value="confirm" />
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
$('input[type=button]').click( function() {
$(":checked").each(function() {
var value = $(this).val();
id = 'id:1';
data = 'shipping:' + value;
console.log(data);
});
$.post("ajax.php", data);
});
</script>
如何在数据中附加 id,使其显示为:
shipping:53
shipping:57
id:1