user1125394
user1125394

Reputation:

redirection not happening without refresh page (php+jqmobile)

I have got a html like this:

<!doctype html>
<html manifest="">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
</head>
<body>
<div data-role="page" id="Find">
    <div data-theme="b" data-role="header" data-position="fixed">
        <h3>test</h3>
    </div>
    <div data-role="content">
        <form action="handler.php" id="findForm" >
            <div data-role="fieldcontain">
                <fieldset data-role="controlgroup">
                    <label for="textinputf1"> keyword: </label> <input id="textinputf1"  name="keyword" placeholder="" value="" type="text" />
                </fieldset>
            </div>
            <input type= "submit" data-theme="g" value="Find" />
        </form>
    </div>
</div>

<div data-role="page" id="Results">
    <div data-theme="b" data-role="header" data-position="fixed">
        <h3>Results</h3>
    </div>
    <div data-role="content">
        <ul data-role="listview" data-filter="true">
            <li><a href="">HEllo</a></li>
            <li><a href="">Bye</a></li>
        </ul>
    </div>
</div>

</body>
</html>​

a handler.php like this:

<?php 
//...
if( let's say false ) {
    header("location:.");
}else{
    header("location:./#Results");
    //header("Refresh:0;url=/application/test/#Results");   
}

with header+refresh or with header+location, when I submit the form, I see this in url bar: .../handler.php?keyword=test

but I'm not redirected, and if I refresh the page (hit enter from the url bar or F5) THEN I get to the #Results, but not automatically

any idea how to fix that?

Upvotes: 0

Views: 1191

Answers (2)

Deepak Keswani
Deepak Keswani

Reputation: 117

Way to see the passed parameters without refresh is by putting data-ajax="false"

If you wish to use ajax, do not call urls directly. Call these with AJAX and based on response redirect to #Results with the help of JavaScript.

Upvotes: 0

bart s
bart s

Reputation: 5110

jquery mobile probably uses ajax to handle your form. You should switch of ajax handling for the form

jQuery Mobile form sample

Also put a space in your location

Location: whereyouwanttogo

Upvotes: 1

Related Questions