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 8339223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:49:39+00:00 2026-06-09T04:49:39+00:00

In jQuery Mobile, I am attempting to run scripts on a page at load

  • 0

In jQuery Mobile, I am attempting to run scripts on a page at load time. If certain criteria are NOT met, I redirect to another page.
For example PageA –> click link to PageB –> perform pageload logic –> Redirect to PageC.
All works well the first time I navigate to the PageB.
If I then return to PageA and repeat the navigation to PageB, the redirect does not occur (the pageload logic is not executed).
If I reload PageA and try again, the redirect does occur.

Seems like some kind of caching issue?? Or perhaps I should be using another type of page load event? How can I ensure the pageload logic is executed everytime the page is hit?

Here is a simplified version of the code. The script is called in the head after jqm and jqm mobile scripts.

$(document).bind('pageload', function (evt,data) {

    // I need the url to see if the page needs the logic executed on it
    var page = $.mobile.path.parseUrl(""+ data.url +"");
    if (page == "PageB"){
        logicRequired = "yes";    
    }
    switch (logicRequired)
    {
    //==========================
    case 'yes':

        // AJAX call to determine if redirect is needed
        $.ajax({
        url: "scripts/file.php",
        async: false,
        cache: false,
        success: function (data){
            if(data.status == 'success') {
              // do some stuff


            } else if(data.status == 'error') {
              //redirect to another page
              window.location.replace('redirectPage.html');
            }
        },
        error: function(data){
            //alert("There was an error in the ajax call");
        },
      });
      break;
      }
});
  • 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-09T04:49:41+00:00Added an answer on June 9, 2026 at 4:49 am

    pageload only fires once each time an external pseudo-page is brought into the DOM. So if you navigate back to that page the event will not fire again. You can however use the pagebeforeshow event which fires on the first visit to a pseudo-page as well as subsequent visits to the pseudo-page.

    You may also be able to flag the specific pseudo-pages with the data-cache="false" attribute so jQuery Mobile deletes the pseudo-page after a user navigates away from the pseudo-page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In JQuery Mobile I am using changePage() to redirect back to a previous page,
I'm attempting to add a link button to a jquery mobile page : http://jsfiddle.net/8JXTT/1/
I am attempting integrate jQuery Mobile into an existing mobile page. I want to
I am attempting to initialize javascript for a jQuery mobile page using the pageInit()
i'm using jquery mobile to load from remote json the information and then put
I am creating a jQuery Mobile page that has two select menu's, one is
Popups in jQuery Mobile not working as intended, please advice. The popup DIV is
I have a Jquery Mobile page into which I'm loading a form via AJAX.
jQuery mobile 1.0 I change the content of the page, to put it simple:
I am attempting to use the jQuery mobile events without the rest of jQuery

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.