Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:55:18+00:00 2026-06-08T23:55:18+00:00

Im currently using Code Igniter to have pretty URLs, and I have this system

  • 0

Im currently using Code Igniter to have pretty URLs, and I have this system that basically uses ajax to allow you to search for gyms.

Im using push state after a list of gyms is loaded, like this:

example.com/list/search_key/pagination-page/sort-by/filters~seperated~by~that

Where search_key is the city, state, or neighborhood in the area they want to search gyms, and filters are individual checkboxes.

What happens, is I use .ajax to send the search key and each individual checkbox value (either 1 or 0) through post, then code igniter uses the POST data and PHP, to generate a url like the one above. The ajax success push states the URL to be the one the PHP generated.

The problem is, that if you use say pagination to go to page-2, and you want to go to page-1, naturally youre going to use the browsers back button. The problem is, that it only backs the URL address bar to the url before hte current one, it doesnt actually change the pages content. I need it to either reload the page using the old (previous) url, or refresh, or something.

I can even use ajax to resubmit the form using the URL data, but I have no clue how to do this.

I have tried a few things, but nothing works at all. Pretty much I’ve tried everything on the first page of google, and everything seems promising but nothing actually works.

Is there anyway to refresh the page, if a pushstate url changes to a previous url?

PS Heres some of the key things Ive tried:

<script type="text/javascript">
$(window).unload(function(e){
   e.preventDefault();
   alert("Back was pressed!");
});
// If this wouldve worked, it wouldve atleast alerted me that.

// The code off this URL: http://www.mrc-productivity.com/techblog/?p=1235

// Some of the codes off this URL: http://forum.jquery.com/topic/howto-force-page-reload-refresh-of-previous-page-when-back-button-is-pressed

// A few others.
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:55:20+00:00Added an answer on June 8, 2026 at 11:55 pm

    Since you are pushing the state from your ajax success method, you can detect the back button using the window.onpopstate method.

    Note that just calling history.pushState() or history.replaceState() won’t trigger a popstate event. The popstate event is only triggered by doing a browser action such as a click on the back button (or calling history.back() in JavaScript).

    var stateObj = { foo: "bar" };
    history.pushState(stateObj, "page 2", "bar.html");
    
    window.onpopstate = function(event) {
        if(event && event.state) {
            // event.state.foo
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using code similar to this: try { // IE ONLY var
I'm currently using this code (per the codex) to show children on parent pages,
I'm currently using this code to calculate the sunrise / sunset times. (To be
I am currently using this code to grab key-strokes, but I am missing e.g.
I am currently using this code to get data from a URL: NSURL *url
I am currently using this code to bring up an info window -(IBAction)showInfo:(id)sender {
I am a rank beginner in C#. I am currently using this code: objGraphics.Clear(SystemColors.Control);
currently i using this code in phonegap application var xmlhttp = new XMLHttpRequest(); xmlhttp.open(GET,http://192.168.1.19:8080/searchMobile?categoryRequest=true,
In my LAMP application (using CodeIgniter), I have a call to $this->db->update... that generates
Currently I have create a website using codeigniter. I got a message error every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.