user1083877
user1083877

Reputation: 121

PHP header() and jquery mobile

I would like to use a php header('Location: newpage.php') to redirect.

I got no error, but Jquery mobile seems to fail loading the destination page and the address bar stays with the old address.

Do you have an advice please ?

Thanks!

Upvotes: 12

Views: 11392

Answers (5)

Kfir Erez
Kfir Erez

Reputation: 3470

I had the same problem on Node.js + JQM and the answer wenkhairu gave fixed it. The problem is that JQM hijacks navigation behavior and use ajax to navigate, if you put data-ajax=false as wenkhairu suggested you tell JQM not to hijack navigation for this form and use regular link/submit behavior

Upvotes: 0

Ian Jamieson
Ian Jamieson

Reputation: 4826

Try turning error reporting on:

ini_set('error_reporting', E_ALL);
ini_set("display_errors","1"); 

Upvotes: -1

Cymbals
Cymbals

Reputation: 1174

I do a header('Location: newpage.php') combined with JQuery Mobile all the time and it works no problem.

I suspect you are trying to send the header after loading any html, which will not work. The php header must occur before any output, including html, JQuery Mobile, etc.

Upvotes: 0

Khairu Aqsara
Khairu Aqsara

Reputation: 1310

try to add data-ajax="false" when you call that page, before redirecting using php header()

Upvotes: 14

James
James

Reputation: 13511

That code sends a 302 redirect header to the user's browser, instructing it to redirect to the provided URL. It should work. Have you checked the syntax? Information here: http://www.php.net/manual/en/function.header.php

Upvotes: 1

Related Questions