私はウェブとスタックを検索していましたが、私の問題を解決する方法が見つからなかったので、誰かが私を助けてくれることを願っています。 「1,3,5,7」のような配列として、ajaxを使用してphpコードに値を送信します
ここに私のコードがあります:
<form id="ShopItemForm" class="ShopItemForm" method="post" name="ShopItemForm">
<input class="ShopItem" checked="checked" name="ShopeItem[]" id="1" value="1" type="checkbox">1
<input class="ShopItem" name="ShopeItem[]" id="2" value="2" type="checkbox">2
<input class="ShopItem" checked="checked" name="ShopeItem[]" id="3" value="3" type="checkbox">3
<input class="ShopItem" name="ShopeItem[]" id="4" value="4" type="checkbox">4
<input class="ShopItem" name="ShopeItem[]" id="5" value="5" type="checkbox">5
<input name="submitShopItem" value="submit" class="button button-push" id="submitShopItem" type="submit">
</form>
$(function() {
$("#submitShopItem").click(function(e) {
e.preventDefault();
// put all checked box to array checkedArray
var shopItem =
$("#shop-item-Loader").html('');
$("#shop-item-Loader").html('load');
$.ajax({
type: "POST",
url: "checked.php",
data: "act=shopItem&ShopItem="+checkedArray,
cache: false,
success: function(html){
alert(checkedArray);
$("#shop-item-Loader").html('');
$("#shop-item-Loader").append(html);
}
});
});
});
カンマ区切りの文字列のように、新しいチェック済みの値をすべて ajax ページに送信したい