<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="subjectSearch fr" />
<script type="text/javascript">
    var lastSearchCondition = '';
    var count = 0;
    function search_hws(e){
        if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
        {
            return;
        }
        lastSearchCondition = $(e.target).val().trim();
        $.ajax({
            url: '<%= url_for({:controller => 'users', :action => 'import_resources_search', :id => User.current.id}) %>'+'?name='+ e.target.value+'&type=<%=type %>'+'&mul_id=<%=@resource_id %>'+'&mul_type=<%=@resource_type %>',
            type:'get'
        });
    }

    function throttle(method,context,e){
        clearTimeout(method.tId);
        method.tId=setTimeout(function(){
            method.call(context,e);
        },500);
    }

    //查询项目
    $("input[name='search']").on('input', function (e) {
        throttle(search_hws,window,e);
    });

</script>