JavaScript to php Error [object HTMLParagraphElement]

/me waves his magic wand

Sure thing

I suspect that the code was inspired from the following post: https://forum.bubble.io/t/known-issue-geolocation-timing-out-in-chrome-65/26304/2

<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>

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

Here is an example of that code working: https://jsfiddle.net/3a0q8wzu/

1 Like