Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Mobile - POST a form and get response

Greetings,

I have the following jquery mobile page:

<div data-role="content">
    <center>
    <img src="./images/logo320.png" />
    </center>

    <br><br>

    <form method="POST" action="./ajax/login.php">
      <label for="login_unameLabel">Username:</label><br>
      <input type="text" name="login_uname" id="login_uname" /><br>

      <label for="login_pwordLabel">Password:</label><br>  
      <input type="password" name="login_pword" id="login_pword" /><br>

      <button id="login_submit" type="submit" data-theme="a">Submit</button>
    </form>
</div>

./ajax/login.php returns either "OK" or "NOK". How can I capture this result in my page?

I keep getting the following error in Firebug:

k.data( [Break On This Error] false)a.mobile.activePage=k;h(k);y&&D&...dd(k).removeClass(" out in reverse "+

It's as if jquery mobile is performing some operation on the result? I don't want this to happen. Do I have to return a valid jquery mobile HTML page from my PHP?

Any insight greatly appreciated.

Many thanks in advance,

Solution: use <input type="button" id="login_submit" data-theme="a" value="Submit" />

Now I can capture click events via:

<script>
$(document).ready(function() {
  $("#login_submit").click(function() {
    alert('clicked');
  });
});
</script>
like image 424
Eamorr Avatar asked Jan 13 '11 12:01

Eamorr


1 Answers

using data-ajax="false" in form.

then you can disable jquery mobile auto ajax call

like image 120
gitee.com Avatar answered Oct 06 '22 23:10

gitee.com