search

Home  >  Q&A  >  body text

javascript - There is this kind of query at the top of every page. How to encapsulate it with ajax and call it repeatedly?

过去多啦不再A梦过去多啦不再A梦2868 days ago455

reply all(3)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:26:59

    1. If you are using popular frameworks, such as ng, react and vue, you can encapsulate it into a component;
    2. If it is a classic HTML page, you can encapsulate the query box and related ajax processing into a sub-page and introduce it with an iframe ; Or encapsulated into a js file, and the html part is generated by js.

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:26:59

    Create a search.js

    Write everything in DOM into js, ​​wouldn’t it be great

    reply
    0
  • 为情所困

    为情所困2017-05-19 10:26:59

    Cache the first query result to sessionStorage, and then obtain it directly from sessionStorage

    reply
    0
  • Cancelreply