0

how can I sent value to JSP by javascript?
I want to sent latitude and longitude parameters to JSP

<body>
<button onclick="getLocation()">click</button>
<script>
function getLocation() {

if (navigator.geolocation)
navigator.geolocation.getCurrentPosition(displayLocation);
else
alert("Oops, no geolocation support");
}

function displayLocation(position) {

var latitude = position.coords.latitude;       // ดึงเอาค่า lat
var longitude = position.coords.longitude;  // ดึงค่า long

}

</script>

</body>

I don't know what form i should do
thnk you very much!

4
Contributors
6
Replies
22
Views
2 Years
Discussion Span
Last Post by janissantony
1

You need a JSP script that will receive the data either via HTTP GET or POST.

Do you want to interact with this JSP page/script via postback or behind the scenes using AJAX?

0

You reference a link that covers asp.net not jsp.

In any case, I'd recommend you use javascript to pass the parameters using Ajax back to the JSP page. You can do this easily using the jQuery library.

http://api.jquery.com/jquery.post/

You'd have to be comfortable with HTML and basic JavaScript to be able to incorporate jQuery in your page.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.