简体   繁体   English

将html5值发送给php

[英]send html5 value to php

hi i have this code for geo location finding 嗨我有这个代码用于地理位置查找

<html>
    <head>
        <title>fs</title>
    <p id="demo"></p>
        <script type="text/javascript">  function get_stored_data() {
alert(localStorage.value); }
var x = document.getElementById("demo");

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}

function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude;  
   }

        </script>
    </head>
    <body>
        <p>The element below will receive content</p>
        <div id="div" />
        <script type="text/javascript">getLocation()</script>
    </body>
</html>

and i want to send the values of the latitude and longitude to php file that will write it in a text file 我想将经度和纬度的值发送到php文件,将其写入文本文件

我使用$ _GET或$ _POST方法将我的数据传递到另一个PHP页面

You have to call ajax and send values. 你必须调用ajax并发送值。 This link may be helpful http://www.w3schools.com/php/php_ajax_database.asp 这个链接可能会有所帮助http://www.w3schools.com/php/php_ajax_database.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM