Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Mobile Form Submit not working

I've seen other similar issues here that have found solutions but after trying them, none work on my case.

I am submitting a form using JQuery Mobile.

After I submit I get a loading message and nothing else.

Does anyone have any ideas?

Here is the relevan code:

in the head:

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Page Title</title> 
    <link rel="stylesheet"  href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>


    <script>
  //reset type=date inputs to text
  $( document ).bind( "mobileinit", function(){
    $.mobile.page.prototype.options.degradeInputs.date = true;
  });   
</script>


</head> 

Then the form:

<form name="form1" method="post" rel="external" action="checklogin.php">


<div class="ui-field-contain ui-body ui-br" data-role="fieldcontain">
 <label class="ui-input-text" for="name">Username:</label>
<input name="myusername" id="myusername" value="" type="text">
</div>

<div class="ui-field-contain ui-body ui-br" data-role="fieldcontain">
 <label class="ui-input-text" for="name">Username:</label>
<input name="mypassword" id="mypassword" value="" type="text">
</div>

<fieldset class="ui-grid-a">
<div><input value="" name="" type="hidden"><button aria-disabled="false" class="ui-btn-hidden" type="submit" data-theme="a">Login</button></div></div>
</fieldset>



</form>

Note: I've added an Echo on the action page but it never gets there.

Any ideas anyone please?

Thanks

like image 812
Satch3000 Avatar asked Apr 24 '11 11:04

Satch3000


2 Answers

jquery mobile use ajax in passing forms, just turn it off and you're good to go

<form action="form1" method="post" data-ajax="false">

like image 97
user2128593 Avatar answered Nov 15 '22 10:11

user2128593


Does your "checklogin.php" file have any <div data-role="page"> tag? If you expect it to load "checklogin.php", then that php file should have some HTML that jQuery mobile recognizes. It will then pull it into your page. If you check your network response to the POST request for "checklogin.php" you will probably see your echo there, but it won't show on the page. Try it.

like image 29
Jay Avatar answered Nov 15 '22 09:11

Jay