weixin_33724659 2014-10-02 15:58 采纳率: 0%
浏览 4

Ajax onkey事件

I am using onkey event with ajax for searching the customer typed input. I got the list of string of what customer typed. The problem is I am not sure how to display the list of string under the text box where customer can select one from that.

<input id="apple" name="apple" type="text" value="" onKeyup="showData(this.value);"/>

function showData(value){

    $.ajax({
        type: "GET",
        cache: false,
        url: "/search/getResults=" + value,
        data: "",
        success:function(ListOfString){

            $.each(ListOfString, function(index, val)
                    {

                    });


    });
};
  • 写回答

2条回答 默认 最新

  • ?yb? 2014-10-02 16:00
    关注

    Try this:

    <input id="apple" name="apple" type="text" value="" onKeyup="showData(this.value);"/>
    <div id="result"></div>
    
    (...)
    success:function(ListOfString){
        for(var index in ListOfString){
            $("#result").append("<p>"+ListOfString[index]+"</p>");
        }
    }
    
    评论

报告相同问题?