Passing values from JavaScript to PHP using AJAX

前端 未结 4 1403
小鲜肉
小鲜肉 2020-12-22 07:12

I don\'t know why my code is not working, I am trying to send the coordinates from JavaScript to PHP using AJAX and I am able to pull values from JavaScript to textbox but v

4条回答
  •  萌比男神i
    2020-12-22 07:28

    You can not execute the PHP script on the samepage3.php, after the page is fully loaded. I suggest to separate the page, and create the response using AJAX. Something like this.

    File index.php

    
    
        
            
            
        
        
             
            
    
            
    
            

    File response.php

    ';
    }
    if (isset($_POST["getlon"]))
    {
        $lon = $_POST["getlon"];
        echo 'Longitude : ', $lon;
    }
    

提交回复
热议问题