【问题标题】:Uncaught SyntaxError: Invalid or unexpected token in script未捕获的 SyntaxError:脚本中的令牌无效或意外
【发布时间】:2019-12-06 04:16:46
【问题描述】:
var abc = "<?php $this->db->where('tv_schedule_status', 'Active'); $this->db->where('tv_schedule_source', 'facebook'); $this->db->order_by('tv_schedule_date', 'asc'); echo $result = $this->db->get('tv_schedule')->row()->tv_schedule_date_time; ?>";

【问题讨论】:

  • 这行代码在浏览器中是什么样子的?
  • 您不能将 PHP 查询分配给 javascript。

标签: javascript codeigniter


【解决方案1】:

您是否尝试删除您的"&lt;?php 和闭包?&gt;"也不要忘记最后一个分号...... 试试这个..<?php echo '<script> var abc = "$this->db->where('tv_schedule_status', 'Active'); $this->db->where('tv_schedule_source', 'facebook'); $this->db->order_by('tv_schedule_date', 'asc'); echo $result = $this->db->get('tv_schedule')->row()->tv_schedule_date_time; "; </script>' ?>

【讨论】:

  • 如果删除 php 会发生什么??
  • 在评论框中提问不是答案
  • @Devsi:正如你所说,我们不能在 var..@Danish 中分配 php..@Danish:抱歉,这里是新手...
猜你喜欢
  • 2016-10-17
  • 2018-08-25
  • 1970-01-01
  • 2020-10-13
  • 2018-01-21
  • 1970-01-01
  • 2019-04-20
  • 1970-01-01
  • 2017-05-02
相关资源
最近更新 更多