javascript - send html5 value to php

461

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

840

Answer

Solution:

I use $_GET or $_POST methods to pass my data to another PHP page

586

Answer

Solution:

You have to call ajax and send values. This link may be helpful http://www.w3schools.com/php/php_ajax_database.asp

People are also looking for solutions to the problem: How to compare two character in php?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.