ki Posted September 26, 2014 Share Posted September 26, 2014 Mind you, I've altered and butchered my code several times trying to find why it's not sending anything even though it says it does. geo.html navigator.geolocation.getCurrentPosition(GetLocation); function GetLocation(location) { var usr_lat = location.coords.latitude; var usr_long = location.coords.longitude; $.ajax({ url: 'local_settings.php', type: 'POST', data: { user_lat : usr_lat, user_long : usr_long }, success: function(data) { alert("success! user_lat:" + data); } }); } local_settings.php if (isset($_POST['user_lat']) && isset($_POST['user_long'])) { $_SESSION['user_lat'] = $_POST['user_lat']; $_SESSION['user_long'] = $_POST['user_long']; } Quote Link to comment https://forums.phpfreaks.com/topic/291288-what-am-i-doing-wrong-sending-variables-to-php/ Share on other sites More sharing options...
CroNiX Posted September 26, 2014 Share Posted September 26, 2014 How do you know it's not sending anything? Your local_settings.php script doesn't return anything back to the ajax, so data does not contain anything in your success() method. It just sets Session vars on the server. Quote Link to comment https://forums.phpfreaks.com/topic/291288-what-am-i-doing-wrong-sending-variables-to-php/#findComment-1492173 Share on other sites More sharing options...
gizmola Posted September 26, 2014 Share Posted September 26, 2014 Cronix is right. You should use firebug to determine if the ajax call is happening. In your code snippet, I don't see you doing a session_start() at the top either. Quote Link to comment https://forums.phpfreaks.com/topic/291288-what-am-i-doing-wrong-sending-variables-to-php/#findComment-1492178 Share on other sites More sharing options...
ki Posted September 29, 2014 Author Share Posted September 29, 2014 How do you know it's not sending anything? Your local_settings.php script doesn't return anything back to the ajax, so data does not contain anything in your success() method. It just sets Session vars on the server. I don't need anything returned, just sent to the server. Cronix is right. You should use firebug to determine if the ajax call is happening. In your code snippet, I don't see you doing a session_start() at the top either. There is a session_start(), I didn't include it in the code I posted. Quote Link to comment https://forums.phpfreaks.com/topic/291288-what-am-i-doing-wrong-sending-variables-to-php/#findComment-1492403 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.