jQuery と Ajax を使用してフォーム データを送信するフォームがありますが、同じ名前と角かっこを持つ入力の値を送信することができません。
入力は次のようになり、異なる値になります。
<input type="text" name="service[]" value="Value 1">
値を取得するための変数は次のとおりです。
var service = $("input[name=service\\[\\]]")
次に、Ajax 経由で送信するデータを収集するための var は次のようになります。
var data = 'name=' + name.val() + '&email=' + email.val() + '&phone=' + phone.val() + '&service=' + service.val() + '&brief=' + encodeURIComponent(brief.val());
次に、メールを送信するためのPHPスクリプトに次のものが含まれています...
$service = $_POST['service'];
$body .= implode(' | ', $service);
So my question is, how do I get the values of the inputs with the name name=service[]
and send them via Ajax.
Thanks in advance :)