JSFiddle - React, Tailwind, and code Playground

by Asim Shariff

HTML

<div id="location">

</div>

JavaScript

window.onload = function() {
                          var startPos;
                          var geoSuccess = function(position) {
                            startPos = position;
                            document.getElementById('startLat').innerHTML = startPos.coords.latitude;
                            document.getElementById('startLon').innerHTML = startPos.coords.longitude; 



                                $.ajax({ 

                                type:'POST', 

                                url:'MyDashboard.php', 

                                data:'latitude='+latitude+'&longitude='+longitude, 

                                success:function(msg){ 

                                            if(msg){ 

                                               $("#location").html(msg); 

                                            }else{ 

                                                $("#location").html('Not Available'); 

                                            } 

                                } 

                                });
                          };
                          navigator.geolocation.getCurrentPosition(geoSuccess);
                        };