weixin_33725126 2016-12-02 15:29 采纳率: 0%
浏览 52

Ajax在popstate事件上

I am trying to handle the popstate event.The problem is that in the same page i use links like:

  1. localhost/item/category
  2. localhost/item/category/subcategory

So i have 2 ajax functions to load contents for each of above examples.When i press the back button of browser, i go back with 2 different ways:

  • localhost/item/category/subcategory2 , to --> localhost/item/category/subcategory1

or

  • localhost/item/category/subcategory to--> localhost/item/category

How can i check every time the url and according to this, call one of my 2 ajax functions to load the correct content?

  • 写回答

1条回答 默认 最新

  • weixin_33691817 2016-12-02 15:57
    关注

    You could use the window.location object to retrieve the current URL https://developer.mozilla.org/fr/docs/Web/API/window/location

    评论

报告相同问题?