Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //HERE IS THE GETGEOY.PHP (getgeoX is just the same...
- <?php
- include '../functions.php';
- session_start();
- if(isset($_POST['id'])){
- $db = connectToDb('julos');
- $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
- $db->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
- $id = $_POST['id'];
- $getGeo = $db->prepare("SELECT Y(geo_position) AS y FROM geo WHERE geo_id = :id");
- $getGeo->execute(['id'=>$id]);
- if (!$getGeo->rowCount()) {
- echo ("false");
- }
- $y = $getGeo->fetchColumn(0);
- $getGeo->closeCursor();
- echo json_encode($y);
- }else{
- echo "ERREUR ID NOT SET";
- }
- ?>
- //////////////////////////////////////////////////////////////////////////////////////////////////
- // here is the problematic JS
- function getGeoX(id){
- return $.ajax({
- type : 'POST',
- url : './php/utils/getGeoX.php',
- data : {'id':id},
- dataType : 'json',
- error : function(response){
- console.log("ERROR GET X "+response.responseText);
- },
- success : function(response){
- console.log("SUCCESS GET X "+response);
- //THIS DISPLAYS THE RIGHT DATA WHICH IS A NUMBER !!!
- }
- });
- }
- function getGeoY(id){
- return $.ajax({
- type : 'POST',
- url : './php/utils/getGeoY.php',
- data : {'id':id},
- dataType : 'json',
- error : function(response){
- console.log("ERROR GET Y "+response.responseText);
- },
- success : function(response){
- console.log("SUCCESS GET Y "+response);
- //THIS DISPLAYS THE RIGHT DATA WHICH IS A NUMBER !!!
- }
- });
- }
- //THE PROBLEM IS IN THE NEXT PART :
- $("body").on("click",".gmLocate",function(){
- $("#idGeo").val(this.id);
- var lat = (getGeoX(this.id));
- var lng = (getGeoY(this.id));
- console.log("DISPLAY LAT : "+lat);
- //THIS CONSOLE LOG DISPLAYS : DISPLAY LAT : [object Object]
- console.log("DISPLAY LNG : "+lng);
- //THIS CONSOLE LOG DISPLAYS : DISPLAY LNG : [object Object]
- //I have to get my value back... when i check what is in this object, i see this in the log :
- // readyState 4
- // responseJSON 50.244641280083
- // responseText "50.244641280083"
- // status 200
- // statusText "OK"
- // ...
- .......................................
- .......................................
- .......................................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement