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.