Solve the Problem of ajax forward and backward Based on Jquery. history, jquery. historyajax

Source: Internet
Author: User

Solve the Problem of ajax forward and backward Based on Jquery. history, jquery. historyajax

The following describes how Jquery. history solves the problem of ajax forward and backward. For more information, see the following.

The premise of this article is based on the background, So seo is not considered here. At the same time, the background-based management system does not need to be added to favorites, so we will not consider refresh such situations as directly hitting the website !!!

Here we use history. state in html5.

The open-source js solution pushState is available on the Internet. For details, see pjax.

However, this solution is not suitable for my project (background Project), especially the main method is not enough.

I am using jquery. history. js. You can refer to this history. js

See the following code.

<!DOCTYPE html>

Username <input id = "txtUser" type = "text"/> <br/>

User id <input id = "txtId" type = "text"/> <br/>

Display result

<Div id = "divtxtinfo"> <input id = "txtinfo" type = "text"/> </div> <br/> <a funname = "displayinfo" title =" wxq "href =" javascript: void (0); "class =" apjax "> submit </a> <br/> log: <textarea id =" log "style =" width: 100%; height: 400px "> </textarea> </body> 

3. Add History. pushState to History and modify the address bar.

4. Execute the method in History. Adapter. bind to get the state parameter first.

5. Change the variable modified by js back to the original value, and change the value of the modified html component back to the original value, restore the html content in the modified html component to the original value,

6. Re-execute the previously executed method, that is, the method saved in CallbackFunctions.

The above content introduces Jquery. history to solve the problem of ajax moving forward and backward. The Code knowledge demonstrates the effect and focuses on the implementation of basic principles. I hope this article will share some benefits that will not be able to bring to you. For more information about jquery moving forward and backward, please stay tuned to the help House website.

Related Article

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.