so I'm writing this form for teams and doing this 'add player' function where you enter a player name in a textfield, check a box for medically ok and click a button which then appends the name to a div above, adds the value to an array and clears the textfield below, like so:
<script>
var players = New Array();
function addPlayer(){
$('#players').append($('#addPlayerField').val());
var playerInfo = New Array($('#addTermCheckbox').prop('checked'),$('#addPlayersField').val());
addingTerms.push(playerInfo);
$('#addPlayerField').val('');
}
</script>
Whats the best way to post the final array to a php script?
Thanks guys!
I would use JQuery's ajax method:
$.ajax({
type: 'POST',
url: url,
data: 'players='+$.toJSON(players),
success: function (data) {}
});