Sto cercando di implementare un semplice script su un sito che restituirà informazioni codificate in base 64 dall'API di ajax di google. Questo è quello che sto giocando con finora:Come codificare base64 all'interno di javascript
<html>
<head>
<script src="http://www.google.com/jsapi?key=ABQIAAAA0duujonFsEX871htGWZBHRS76H0qhS7Lb-D1Gd0Mnaiuid8Z7BQIyz2kMpojKizoyiCQA4yRkKAKug" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
var location = 'Unable to determine your location.';
if (google.loader.ClientLocation) {
var loc = google.loader.ClientLocation;
location = 'Country: <strong>' + loc.address.country + '</strong>, Region: <strong>' + loc.address.region + '</strong>, City: <strong>' +
loc.address.city + '</strong>, Lat/Long: <strong>' + loc.latitude + ', ' + loc.longitude + '</strong>';
}
jQuery('.geolocation').html(location);
});
</script>
</head>
<body>
<span class="geolocation"></span>
</body>
</html>
Esso restituisce informazioni che sto cercando di ottenere correttamente, ma ho bisogno di base64 codificare le parti separate, come paese, regione, città, lat e longitudine. In PHP sarebbe semplice, ma non riesco a capire come farlo in javascript. Qualsiasi aiuto sarebbe apprezzato.
possibile duplicato di [Come è possibile codificare in Base64 utilizzando Javascript?] (Http://stackoverflow.com/questions/246801/how-can-you-encode-to-base64-using-javascript) –