【问题标题】:Bootstrap modal - remote-data url引导模式 - 远程数据 url
【发布时间】:2016-07-12 09:38:24
【问题描述】:

我有一个使用 php 生成的按钮,它调用引导模式:

echo '<button class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target="#remote-modal" data-remote="printlist.php?type=rangeddetail&pid='.$pid.'&startdate='.$startdate.'&enddate='.$enddate.'&storeformat='.$storeformat.'&retailer='.$retailer.'">'.$ranged_v.'</a>'

data-remote 属性在 html 中呈现时是这样结束的:

data-remote="printlist.php?type=rangeddetail&pid=xxx&startdate=2016-07-05&enddate=2016-07-12&storeformat='x 1','x2','x3','x 4','x5'&retailer='r x'"

这会在按下按钮时带来错误:

jquery-1.12.0.min.js:2 Uncaught Error: Syntax error, unrecognized expression: 1','x2','x3','x 4','x5'&retailer='r x'

我怎样才能做到这一点?

【问题讨论】:

  • 在 php 中使用 str_replace("\'", "", $storeformat) 和 str_replace("\'", "", $retailer)
  • 为什么要在 x 和 4 之间留出空格,它可能是这样的 'x4' 或显示你的脚本
  • storeformat 和retailer 来自一个来自mysql 的ajax 调用的数组,格式为逗号分隔值。有些值是 2 个带空格的单词,甚至是 3 个带空格的单词

标签: php jquery twitter-bootstrap modal-dialog bootstrap-modal


【解决方案1】:

我找到了,看来我必须包装导致 urlencode 问题的变量:

'printlist.php?type=rangeddetail&pid='.$pid.'&startdate='.$startdate.'&enddate='.$enddate.'&storeformat='.urlencode($storeformat).'&retailer='.urlencode($retailer);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2013-08-10
    • 2014-02-22
    相关资源
    最近更新 更多