-1

I'm building a mobile website using jQuery Mobile and PHP.

Currently, when I submit a form with PHP, it redirects me to the previous page.

However, I want to stay on the same page.

Here's my code:

<form action="#" method="post" data-ajax="false">
    <center>
        <div data-role="page">  

            <div data-role="collapsible"  data-iconpos="right" data-theme="a"  style="width:500px">
               <h3>Offer 1</h3>
               <img src="images/special1.jpg"/>
               <h3>Valid through: 06/30/2013</h3>
                   <div data-role="collapsible" data-collapsed="true"  data-iconpos="right" data-theme="a"  style="width:400px; background-color:#FFFFFF">
                       <h3>Redeem this offer</h3>
                    <div >

                    <h4 style="color:#CC0000"> To be used by our staff only!</h4>
                    <p style="color:#CC0000;font-family:Arial, Helvetica, sans-serif">Do <strong>not</strong> press the Redeem button now. Ask our store associate for assistance.</p>
                    <input type="submit"  name="offer1btn" value="Redeem"  data-theme="b" style="background:#FF0000 !important"/>
                </div>
            <div style="display:none">
                <h4 style="color:#CC0000">Offer has been Taken</h4>
            </div>
        </div>
    </center>
</form>
Littm
  • 4,923
  • 4
  • 30
  • 38
Danish Ahmad
  • 75
  • 1
  • 1
  • 12

2 Answers2

0

Or you can use

      action="<?php echo $_SERVER['PHP_SELF'];?>"

hope that helps.

Dharmendra
  • 216
  • 1
  • 14
0

jQuery Mobile is a little bit specific with form submitting. If you disable classic jQuery Mobile form handling with data-ajax="false" attribute then only correct way to submit a form is through $.ajax call.

I made a working example here: jQuery Mobile: How to correctly submit form data

Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130