查询字符串的第一个参数不是作为GET参数在AJAX调用上发送的,为什么?

时间:2016-11-07 14:27:12

标签: javascript php jquery select2 jquery-select2-4

我正在使用此代码在Select2元素中发送AJAX调用:

var condition_type = 'something'; // this is dynamic but I turned on a string for demonstration
var field_value = 'something_1'; // this is dynamic but I turned on a string for demonstration

$('#condition_value_1').select2({
  placeholder: 'Start typing ...',
  allowClear: true,
  tags: true,
  ajax: {
    url: '/search',
    dataType: 'json',
    minimumInputLength: 2,
    delay: 250,
    data: function(params) {
      return {
        keyword: params.term,
        condition: condition_type,
        field: field_value
      };
    },
    processResults: function(data) {
      return {
        results: data.items
      };
    }
  }
});

上面的代码有效,并且正在发送一个具有以下结构的AJAX请求:

/search?keyword=some&condition=something&field=something_1

我应该得到三个GET参数,但我只得到最后两个,我不知道为什么会出现这种情况。看看phpStorm的调试窗口:

enter image description here

请注意conditionfield如何成为REQUEST的一部分,并作为GET参数传递,但第一个keyword在哪里?不应该也是REQUEST的一部分吗?我在配置PHP或Select2时遗漏了什么?

0 个答案:

没有答案