I would like to fill input field with javascript ipinfo API response. I am ready to fill a PRE but not an INPUT. I need to send it by a form in order to save this information.
Please see it here http://jsfiddle.net/ak2txped/2/
$(window).load(function(){
$.get("http://ipinfo.io", function(response) {
$("#ip").html(response.ip);
$("#code").html(response.country);
$("#address").html("Location: " + response.city + ", " +
response.region);
$("#details").html(JSON.stringify(response, null, 4));
}, "jsonp");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<pre id="details"></pre>
<form id="details" action="/action_page.php" method="post">
Details: <input type="text" name="fname" value="pre"><br>
<input type="submit" value="Submit">
</form>
Thanks in advance