I have been searching high and low to come up with a solution to an error I am getting with a phonegap app I am building.
HTML
<form method="post" id="app-send" name="app-send">
<input id="a" name="a" type="text">
<input id="b" name="b" type="text">
<input id="c" name="c" type="text">
<input id="timestamp" name="timestamp" type="text">
<input id="submit" name="submit" type="submit">
</form>
JS
<script type="text/javascript">
$(document).ready(function () {
$('#app-send').submit(function (e) {
var postData = $(this).serialize();
$.ajax({
type: 'POST',
url: 'http://example.com',
dataType: 'json',
data: postData,
success: function (data) {
alert(data);
},
error: function () {
alert('error!');
}
});
return false;
});
});
</script>
My Issue:
Everytime I test on phonegap developer app in the console I get back
"Proxy error for url: http://example.com undefined"
"HPE_INVALID_CONTACT http://example.com"
UPDATE
I have just tried this:
<form action="http://www.example.com" method="post" id="app-send" name="app-send">
<input id="a" name="a" type="text">
<input id="b" name="b" type="text">
<input id="c" name="c" type="text">
<input id="timestamp" name="timestamp" type="text">
<input id="submit" name="submit" type="submit">
</form>
And this works. So how could I submit the data using AJax and stop the page from changing?