How to refresh a page with jQuery by passing a parameter to URL

后端 未结 9 1472
借酒劲吻你
借酒劲吻你 2020-12-13 17:04

I am refreshing my page using jQuery:

location.reload();

This is working great but I want to refresh the same page by passing a parameter t

9条回答
  •  星月不相逢
    2020-12-13 17:52

    Click these links to see these more flexible and robust solutions. They're answers to a similar question:

    • With jQuery and the query plug-in: window.location.search = jQuery.query.set('single', true);
    • Without jQuery: Use parse and stringify on window.location.search

    These allow you to programmatically set the parameter, and, unlike the other hacks suggested for this question, won't break for URLs that already have a parameter, or if something else isn't quite what you thought might happen.

提交回复
热议问题