1

I want to know what code do I need to save the data that JavaScript displays to SQL Database

I'm inside the Create View of my Controller. This is my code on the Create view that display my Javascript:

<div>
<script>
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition, showError);
    }
    else { $("#message").html("Geolocation is not supported by this 
    browser."); }

    function showPosition(position) {
        var latitude = position.coords.latitude;
        var longitude = position.coords.longitude;
        var latlon = "Latitude: " + latitude + "<br/>" + "Longitude: " + 
        longitude;
        $("#message").html(latlon);
    }
</script>
//This Display Latitude and Longitude
<p id="message"></p>
</div>

This code is Inside the Create.CSHTML file above its default code. It will show my current Latitude and Longitude values. I need to make it save those values in SQL

adrianex03
  • 83
  • 6
  • You need a data layer. You create a Service api to receive the data from a Jquery https://stackoverflow.com/questions/19557184/how-to-pass-json-data-to-restful-web-services-through-ajax-and-also-how-to-get-j – Juan Carlos Oropeza Jun 05 '18 at 18:41
  • thanks, I have the data provided from JS, I only need that data to be on the Create spaces that the controller provides – adrianex03 Jun 05 '18 at 21:00

0 Answers0