I want to ask you how to call the REST Service from cordova application. I use the MongoDB as stored data. I want to add data from index.html to MongoDB. I can access the url localhost:28017/AlitaDB/test/ from browser and display data from MongoDB. Here the code index.html
index.html
<!DOCTYPE html>
<html>
<head>
<title>Manage Contact</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.4.8.js"></script>
<script src="js/jquery-1.11.1.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("#submit").click(function insertContact(){
$.post("http://localhost:28017/AlitaDB/test/",
$("#insertContact :input").serializeArray(),
function(json){
if(json== null || json == 'undefined')
alert("Insert failed");
else
alert("Insert successful");
});
alert('asdas');
return false;
});
});
</script>
</head>
<body>
<h3>Insert Contact</h3>
<form id="insertContact">
<table>
<tr>
<td>Contact Id</td>
<td><input type="text" name="contactId" /></td>
</tr>
<tr>
<td>First Name</td>
<td><input type="text" name="firstName" /></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="lastName" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td><input type="submit" id="submit" name="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>