I am trying to send some formdata to a remote server in phonegap using jQuery and Ajax. The code I inserted below works fine in firefox on my local machine, but it will not work when I run it on my phone (Android). Do I need to modify or add something to jquery code to make it work in phonegap?
I added INTERNET permission in android manifest.
<!DOCTYPE HTML> <html> <head> <title>Phonegap ajax test</title> <meta name="viewport" content="width=240, height=320, user-scalable=yes, initial-scale=2.5, maximum-scale=5.0, minimum-scale=1.0" /> <script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script> <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script> <script type="text/javascript" charset="utf-8" src="js/jquery.mobile-1.0rc2.js"></script> <link rel="stylesheet" type="text/css" href="css/layout.css" /> <link rel="stylesheet" type="text/css" href="js/jquery.mobile-1.0rc2.css" /> <script type="text/javascript"> $(document).ready(function() { $('#infoForm').submit(function() { var postTo = 'http://www.mysite.com/process.php'; $.post(postTo,$('#infoForm').serialize(), function(data) { alert(data); }); return false; }); }); </script> </head> <body> <div data-role="content"> <form method="post" id="infoForm"> <input type="text" name="first_name" id="first_name" value="" placeholder="First Name" /> <input type="text" name="last_name" id="last_name" value="" placeholder="Last Name" /> <input type="text" name="email" id="email" value="" placeholder="Email" /> <button type="submit">Submit</button> </form> </div> </body> </html>
Thanks!
source share