最後一個線程充滿了錯誤,粘貼時發生錯誤。用PhoneGap發送一個PHP表格
首先,我一直在玩PhoneGap,我最終試圖做的是建立一個聯繫表單的應用程序,將結果通過電子郵件發送到我選擇的電子郵件(以及一張圖片攝像頭應用程序)(或結果發佈到服務器甚至)
我發現this,我一直在試圖複製它,以得到我的表單將如何工作,但是,我似乎無法讓它運行。
繼承人一步一步的我到目前爲止。
的index.html - >只鏈接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(我的遠程服務器上)
<?php
require_once("class.phpmailer.php");
$MessageText=$_POST["msg"];
$mailer = new PHPMailer();
$mailer->isSMTP();
$mailer->CharSet='utf-8';
$mailer->AddAddress("[email protected]", "Gabe");
$mailer->Subject="Mobile App Message";
$mailer->From = '[email protected]';
$mailer->Body = $MessageText;
//VALIDATION
if(
empty($MessageText)
) {
echo "Error";
} else {
$mailer->Send();
echo "Success";
}
?>
index.js(其中即時保持我的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;
}
});
});
});
我試過以下步驟here和here,但似乎無法弄清楚什麼是錯的......當我點擊提交時,絕對沒有任何反應。
我的PHP文件有效,如果我通過this提交,它會迴應成功併發送電子郵件。
如果我改變我的PHP提交而不是按鈕,它的工作原理,但這只是使用HTML和PHP,而不是應用程序本身的實際JS。
是否有什麼你JS錯誤控制檯? – BenOfTheNorth 2013-03-04 01:26:27
超時錯誤:( – 2013-03-04 01:36:11
哦,它的說話無法打開文件閱讀 – 2013-03-04 01:37:54