02-unit08: Search notes function, search paging, handle inserting database garbled problem

Source: Internet
Author: User
Tags button type

Search notes function Key listener events
    $("#search_note").keydown(function(event){        var code=event.keyCode;        if(code==13){            请求发送        }    })

SELECT * from GBshare cnshare_title like '% '

Send an AJAX request
    • Event bindings: Keyboard Listener events (KeyDown)

    • Get parameters: keyword, as the basis for fuzzy queries

    • Send request:/share/find.do

Server processing
    • Sharecontroller.searchnote (String keyword)

    • Shareservice.searchnote (String keyword)

      String title="%";if(keyword!=null){    title="%"+keyword+"%";}shareDao.findLikeTitle(title);
      1. Do not enter keywords to achieve full table query ('% ')

      2. Input keywords for fuzzy query ('%keyword% ')

    • Sharedao.findliketitle (String keyword)

    • Mapper:select *

          from cn_share     where cn_share_title like #{keyword}
Ajax callback Processing
    • Success

      1. PCPart 6 show, hide pcPart 2

      2. Add an LI element to the list of $ ("#search_ul")

        sli+= '

      3. ‘;

        sli+= ";

        sli+= ' <i class= "fa fa-file-text-o" title= "online"

        Rel= "Tooltip-bottom" > ";

        Sli+=sharetitle;

        sli+= ' <button type= "button" class= "Btn Btn-default Btn-xs

        BTNposition btnslide_down "><i class=" FA fa-chevron-

        Down ">";

        sli+= ";

        sli+= '

      4. ‘;
    • Error: Prompt to search for notes failed

Search for paging requirements
    select * from cn_share     where cn_share_title like #{title}    limit #{begin},3    n:抓取记录的起点,从0开始(0表示第一条)    m:抓取记录的最大数    1 - 0    2 - 3    3 - 6    n - (n-1)*3
Handling Insert Database garbled problem
    "jdbc:mysql:///cloud_note?    useUnicode=true&amp;charaterEncoding=utf8"
Jobs: The paging feature for searching shared notes (focus)

02-unit08: Search Notes feature, search paging, handle inserting database garbled issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.