我是Cordova應用程序中的新成員。我想問你如何使用php和MongoDB在cordova應用程序中從表單發佈數據。我在c:/ xampp/htdocs中的cordova app和comment.php中有index.html。我想在index.html的comment.php中顯示數據。這裏的代碼。這是index.html,然後comment.php如何使用php和MongoDB發佈Cordova應用程序中的數據
的index.html
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script>
$.ajax({
type : "POST",
url : "comment.php",
crossDomain: true,
beforeSend : function() {$.mobile.loading('show')},
complete : function() {$.mobile.loading('hide')},
data : {email : 'email', comment : 'comment'},
dataType : 'json',
success : function(response) {
//console.error(JSON.stringify(response));
alert('Works!');
},
error : function() {
//console.error("error");
alert('Not working!');
}
});
</script>
</head>
<body>
<script>
document.addEventListener("deviceready", function() {
new kendo.mobile.Application(document.body, {
statusBarStyle: "black-translucent"
});
}, false);
</script>
<div data-role="page" id="index">
<div data-theme="b" data-role="header">
<h1>Index page</h1>
</div>
<div data-role="content">
</div>
</div>
</body>
</html>
comment.php
$email = isset($_POST['email']) ? $_POST['email'] : '';
echo $email;
$comment = isset($_POST['comment']) ? $_POST['comment'] : '';
echo $comment;