Website:
<div><input type="checkbox" name="List[]" value="1"></div>
<div><input type="checkbox" name="List[]" value="2"></div>
<div><input type="checkbox" name="List[]" value="3"></div>
<div><input type="checkbox" name="List[]" value="2"></div>
<div><input type="checkbox" name="List[]" value="3"></div>
js code:
var valArr= [];
$('input:checkbox[name^="List[]"]:checked').each(function(){
valArr.push($(this).val());
});
valArr = JSON.stringify(valArr);
$.post(<YOUR SERVER URL>,
{
type: 'post',
data: valArr,
});
$('input:checkbox[name^="List[]"]:checked').each(function(){
valArr.push($(this).val());
});
valArr = JSON.stringify(valArr);
$.post(<YOUR SERVER URL>,
{
type: 'post',
data: valArr,
});
PHP server:
$list = json_decode($request->data, true);
var_dump($list);
var_dump($list);
沒有留言:
張貼留言