mardi 15 avril 2014

How do I send data from phonegap to an express app?


Vote count:

0




I'm trying to make an ajax post request inside of phonegap, and then receive that data inside of an express app. This is what my code looks like:


Phonegap:



$.ajax({
type: 'POST',
url:"http://localhost:3000/test",
data: {'test':'test'},
dataType: 'jsonp',
crossDomain: true,
success: function(data){
console.log('data successfully sent');
},
error: function(){
console.log('there was an error');
}
});


Express:



app.get('/test' , function (req , res){
console.log(req.body);
res.redirect('/');
});


Inside of my express console I am seeing an empty object. Inside the phonegap console it is logging an error.


Does anybody know what I'm missing here? Is this even the right direction for being able to send data from phonegap to express? I want to eventually store the data inside of a mongodb once it hits the express app.


Please let me know. Thanks!



asked 2 mins ago






Aucun commentaire:

Enregistrer un commentaire