dsoy71058 2015-08-29 11:54
浏览 23

ajax使用horsey插件无法正常工作

I need to have something like this ajax:

<script type="text/javascript">
    function gettheresults() {
        $.ajax({
            type: 'post',
            url : '{{ path("client_medical_category_search") }}',
            data: 'asas',
            success: function(result) {
                console.log(result);
                horsey(document.querySelector('#ssSearchParam'), {
                    suggestions: result,
                    limit: 10
                });
            }
        });
    }
    gettheresults();
</script>

<input value="{{ ssSerachParam }}" id="ssSearchParam" name="ssSearchParam" type="text" class="form-control"
               placeholder="{{'Search for clinic, treatment, doctor'|trans}}">

I am loading results via ajax from database. But it gets the results only after 1~3 seconds and it doesn't attaches to my input field anymore. If i do console.log(), i see the results are good. If i do without ajax, via PHP, it attaches ok. But i need this via ajax. What is the problem here, how can i make it to be attached to my search input field after delayed time?

I need horsey for fuzzyesearch. This ajax call is for mainly for horsey, that my fuzzysearch would have the results in which it would search. And it should append to my input field.

I have working only this part:

$(document).ready(function () {
    void function () {
        'use strict';

        horsey(document.querySelector('#ssSearchParam'), {
            suggestions: ['airia', 'argentina', 'germany', 'etc'],
            limit: 10
        });

    }();

});

I need to get the suggestions to horsey via ajax.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?