Last thread was riddled with errors, made a mistake when pasting it.
To start off, I've been playing around with PhoneGap, and what I'm trying to do eventually is build an app with a contact form that will email the results to an email of my choice (along with a picture taken in the camera app) (or post results to a server even)
I found this and I've been trying to replicate it to get a starting feel of how my form would work, however, I can't seem to get it running.
Heres a step by step of what I have so far.
Index.html -> Just links to callsheet.html
callsheet.html
<!DOCTYPE html>
<html>
<head>
<title>Send in CallSheet</title>
<script type="text/javascript" charset="utf-8" src="js/cordova-2.5.0.js"></script>
<script type = "text/javascript" charset="utf-8" src="js/index.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to connect with the device
//
document.addEventListener("deviceready",onDeviceReady,false);
</script>
</head>
<body>
<form action="http://contest.phoenixamd.com/ANDROIDTEST/callsheet.php" method="post">
<div class="form-element">
<label for="msg">Message</label>
<textarea id="msg" name="msg" placeholder="required" rows="5" required ></textarea>
</div>
<input type="button" value="submit contact"/>
</form>
</body>
</html>
callsheet.php (on my remote server)
<?php
require_once("class.phpmailer.php");
$MessageText=$_POST["msg"];
$mailer = new PHPMailer();
$mailer->isSMTP();
$mailer->CharSet='utf-8';
$mailer->AddAddress("gabesteinberg@me.com", "Gabe");
$mailer->Subject="Mobile App Message";
$mailer->From = 'test@phoenixamd.com';
$mailer->Body = $MessageText;
//VALIDATION
if(
empty($MessageText)
) {
echo "Error";
} else {
$mailer->Send();
echo "Success";
}
?>
index.js (where im keeping my jquery)
// When the document has loaded...
$(document).ready(function() {
// Bind this action as a function to be executed when the button is clicked...
$('input[type="button"][value="submit"]').click(function() {
$.post('http://contest.phoenixamd.com/ANDROIDTEST/callsheet.php', {
MessageText: $('#msg').val()
// HTML function
}, function (html) {
// Place the HTML in a astring
var response=html;
// PHP was done and email sent
if (response=="Success") {
alert("Message sent!");
} else {
// Error postback
alert("Please fill all fields!");
return false;
}
});
});
});
I've tried following steps taken here and here but cant seem to figure out whats wrong... When I hit submit, absolutely nothing happens.
My PHP file works, and if I submit via this it echoes success and sends the email.
If I change my php to submit instead of button, it works, but thats just using the html and php, not the actual JS of the app itself.