I'm building a hybrid app using HTML 5 geoLocation and jQuery-mobile, when trying to send data to my server from a web browser the data sending\receiving works great but when i change the web browser to my mobile phone web browser the data at the server side is "NaN" - not a number(Node parsing i believe) :
[CastError: cast to number failed for value "NaN" at path "QueryCasting"]
The request is ajax-jquery that include the geoLocation:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
}
function showPosition(position) {
currentLatitude = position.coords.latitude;
currentLongitude = position.coords.longitude;
localStorage.DeviceLocation=currentLatitude+","+currentLongitude;
}
Anyone tried to send geoLocation data to a node.js-mongoDB server, I suspect that the problem is in the currentLatitude, currentLongitude vars. Important thing is the phone browser isn't requesting me for my permission to use location. Before sending the data, I use .serializeJSON() I dont know if the problem is related to that, again I must say that the app is working fine on a laptop browser. Here is my jQuery-ajax request :
$('#GoButton').click (function () {
var workerData = $("#workerForm").serializeJSON();
workerData.lat = currentLatitude;
workerData.lng = currentLongitude;
$.ajax({
type: "GET",
dataType:'json', // to json once server side is OK
data: {valArray:workerData},
crossDomain: true,
url:'http://ift.tt/1NWOGA3',
//handle response - checks json format, statueCode (200,304)
Maybe the problem is with the request? or the crossDomain: true?
Thank you.
Aucun commentaire:
Enregistrer un commentaire