javascript - 将 html5 值发送到 php

标签 javascript php html

嗨,我有这个用于地理位置查找的代码

<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>

我想将纬度和经度的值发送到 php 文件 这会将其写入文本文件

最佳答案

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

关于javascript - 将 html5 值发送到 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40817057/

相关文章:

php - 编写正则表达式以在 laravel 项目中查找翻译

php - 获取 Controller 内的当前 default_target_path

javascript - Div 不知道屏幕大小调整

html - 使用 R 在 imdb 中抓取网页

Javascript:是否存在一种情况,人们更愿意使用原型(prototype)来声明对象属性?

javascript - 如何使用C#控制台同时进行输入和日志记录

javascript - 使用 react 测试库检查文本出现在元素内部

php - 最简单的内容管理框架

javascript - 如何在选择另一个按钮时停止脚本

javascript - 如何访问 knockout 组件模板中的 View 模型变量?