Kumar Kush
Kumar Kush

Reputation: 2586

Why aren't styles loading in second page in jQuery mobile?

Below is the part of screenshot of mywebsite/index.php, a PC site with NO jQuery Mobile (JQM), with all scripts and styles.

enter image description here

Below the screenshot of mywebsite/mobile/options.php, a page designed to be run on mobile browsers, having JQM.

enter image description here

Here is the HTML script for Logout button, actually an ahchor tag:

<a href="../logout.php" data-role="button" data-mini="true" data-icon="delete" data-inline="true" data-ajax="false">Logout</a>

.. refers to the main mywebsite folder out from mobile folder.

When I tap/click Logout, it should go to mywebsite/index.php, the PC site. And here's what shows up:

enter image description here

If I display the location using alert(document.location);, it shows - mywebsite/mobile/options.php.

I have to press F5 to view the page as it should.

I know that this is happening because JQM loads the pages AJAXually and hence ignores all scripts and stylesheets outside of BODY tag. I know this question is duplicate of many questions in StackOverflow and I have tried my level best to find a solution, but can't find one.

How do I move to the index.php without need to refresh?

Upvotes: 0

Views: 112

Answers (1)

SDH
SDH

Reputation: 391

You need to add additional code to your logout.php file to execute after the logout code executes. PHP headers can accomplish this. Within your PHP tags, add this to the end of your code:

header( 'Location: http://mywebsite/index.php' ) ;

Upvotes: 1

Related Questions