0

使用多维数组时,我的`$_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'];
4

2 回答 2

6

注意引号,f.ex 这个:

'<input type="hidden" name="vidid[" + videocounter + "]

应该是

'<input type="hidden" name="vidid[' + videocounter + ']

您可以在 SO 的语法突出显示中轻松发现这一点,

于 2013-01-30T18:28:49.130 回答
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 + '" />');
于 2013-01-30T18:32:00.730 回答