Hello all,
I am trying to make use of Google's API as a way to get the location of the user. Once I have done this, I pass this to an external PHP script which will further output some JavaScript code. However, I am having trouble calling the PHP script:
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAKw7Q"></script
<script type="text/javascript">
if(google.loader.ClientLocation)
{
visitor_countrycode = google.loader.ClientLocation.address.country_code;
}
</script>
<script type='text/javascript' src='http://www.mysite.com/widget.php?mid=12&c=visitor_countrycode'>
</script>
The above is what is retreived from my DB. However the variable visitor_countrycode
does not get generated in the HTML it still contains the string "visitor_countrycode
" rather than its Javascript value.
I just can't figure it out.
Update
I actually can use JQuery:
I have tried this but I didn't get much luck with it.
$("<script type='text/javascript' scr='http://www.mysite.com/widget.php?mid=12&c="+visitor_countrycode+"'").appendTo('body');
Anything wrong with it?