passing array from php to javascript

前端 未结 3 1658
再見小時候
再見小時候 2021-01-25 02:18

Hello I\'m trying to pass several arrays from php to javascript. For some of them it works, for others not. I get an array of filenames and an array which contains the content o

3条回答
  •  无人共我
    2021-01-25 02:30

    Some general advice:

    1. It's difficult to troubleshoot this kind of problem without the error message. If no error is being printed where you can see it, look for files named php.log, error.log, or httpd.log or ask your server admin(s).
    2. Try using print_r() on your arrays to see if there's any difference in how they're structured. For example, just after setting the arrays in PHP:

      print_r($fileArray);
      print_r($listTextArray);
      print_r($falseArray);
      
    3. Rather than constructing the JS arrays via loops, try using the built-in json_encode() function instead. This both simplifies your PHP code and may cause more useful error messages when there are problems:

      var filesArray=;
      var falseArray=;
      var textListArray=;
      

提交回复
热议问题