Hello Eddy and thank you for your great work. Vital Plugin.
I've just switch to WKWebView in my cordova App. So far no pb and everything loads perfectly from local server. All 9 plugins work fine (Fb, geolocation ..)
I'm having an issue when sending AJAX requests, they are being sent twice. The first one without headers which trigger bugs n the app :
As you can see, the first request doesn't have X-API-KEY in the requests header when the second one does as expected.
Also you can see all requests are being sent twice for some reason. Any idea on this ?
triggerFriendsWall: function() {
//Get location
var options = {
timeout: 30000,
enableHighAccuracy: true,
maximumAge: 90000
};
//We need to check if user has disabled geolocation, in which case it makes the app crashes ! (from Cordova.js 1097)
var position = JSON.parse(localStorage.getItem("position"));
if (position == "" || position == null || position == "null" || typeof position == "undefined" ) {
// In this case we have never set location to anything and the user has enabled it.
navigator.geolocation.getCurrentPosition( function(position) {
home.friendsWall(position);
}, function(error) {
common.handle_errors(error, home.friendsWall);
}, options);
} else {
// in this case, user has disabled geolocatoin !
common.handle_errors(false, home.friendsWall);
}
},
friendsWall: function(position) {
$.when(UserDAO.getUsersNearby(position.coords.latitude, position.coords.longitude, home.Usr_radius, home.Usr_limit, home.Usr_offset))
.done(function(response) {
// Do stuff
})
}
getUsersNearby: function(lat, lng, radius, limit, offset) {
var key = localStorage.getItem("key");
return $.ajax({
type: "GET",
url: config.server_url + 'user/usersSurrounding',
headers: {
'X-API-KEY': key
},
data: {
lat: lat,
lng: lng,
radius: radius,
limit: limit,
offset: offset
},
dataType: 'json'
});
},
It does fo to friendsWall, and then trigger.
I've updated all my web servers controlers to meet CORS requirements.
@MilesYM This is because you are using a custom "header" for X-API-KEY, which will force the webserver (localhost), to run OPTIONS before doing. Check this gist out: https://gist.github.com/revolunet/6295643
Hello Eddy and thank you for your great work. Vital Plugin.
I've just switch to WKWebView in my cordova App. So far no pb and everything loads perfectly from local server. All 9 plugins work fine (Fb, geolocation ..)
I'm having an issue when sending AJAX requests, they are being sent twice. The first one without headers which trigger bugs n the app :
As you can see, the first request doesn't have X-API-KEY in the requests header when the second one does as expected.
Also you can see all requests are being sent twice for some reason. Any idea on this ?
It does fo to friendsWall, and then trigger. I've updated all my web servers controlers to meet CORS requirements.
What should I do ? where should I look ?
Thanks for your help.