【问题标题】:Using select2 typeahead with a url outside the web root将 select2 typeahead 与 Web 根目录之外的 url 一起使用
【发布时间】:2014-05-06 18:11:21
【问题描述】:

如何让 select2 访问 web 根目录之外的 url 以进行 db 查询选择?

我有这个:

$('#payees').select2({
    minimumInputLength: 2,
    ajax: {
      url: "/connectors/search-connector.php",
      dataType: 'json',
      data: function (term, page) {
        return {
          q: term
        };
      },
      results: function (data, page) {
        return { results: data };
      }
    }
  });

我希望 /connectors/search-connector.php 实际上位于 Web 根目录之外 [无法通过 Web 访问] ~ 现在我知道我可以使用 PHP 做到这一点,但 select2 会在需要的 url 末尾附加一个查询字符串以某种方式被捕获并通过。

这可以吗?

【问题讨论】:

    标签: php jquery jquery-select2 typeahead.js


    【解决方案1】:

    如果这些文件位于 Web 根目录之外或无法从公共 URL 访问,则您无法使用 javascript 访问 php 文件。 尝试先创建一个带有公共 URL 的 php,此文件将调用私有文件

    【讨论】:

      猜你喜欢
      • 2012-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      • 2017-11-21
      • 2016-10-31
      • 1970-01-01
      相关资源
      最近更新 更多