在使用多维数组时,我在`$ _POST中继续获得vidid
的未定义索引,我不知道为什么会得到这个?
以下是jquery:
var videocounter = 0;
function stopVideoUpload(success, videoID, videofilename){
var result = '';
videocounter++;
if (success == 1){
result = '<span class="videomsg'+videocounter+'">The file was uploaded successfully</span>';
$('.hiddenvid').append('<input type="hidden" name="vidid[" + videocounter + "][]" id="'+videoID+'" value="' + videoID + '" />');
return true;
}
以下是$ _POST:
$vidresults = $_POST['vidid'];
答案 0 :(得分:6)
注意引号,f.ex:
'<input type="hidden" name="vidid[" + videocounter + "]
应该是
'<input type="hidden" name="vidid[' + videocounter + ']
您可以在SO,
的语法高亮显示中轻松发现这一点答案 1 :(得分:0)
糟糕的报价。变化:
$('.hiddenvid').append('<input type="hidden" name="vidid[" + videocounter + "][]" id="'+videoID+'" value="' + videoID + '" />');
要:
$('.hiddenvid').append('<input type="hidden" name="vidid[' + videocounter + '][]" id="'+videoID+'" value="' + videoID + '" />');