In Index.html I have:
<head>
<script>
$(function(){ $(".myDIV").load("page.htm?city=London"); });
</script>
</head>
<body>
<div class="myDIV"></div>
</body>
everything works except parameter ?city=London
I mean page.htm is opening inside index.htm but parameter city is not visible. Should it works?
In page.htm I have
<script>
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
</script>
and finally
<div class="city"></div>
<script>
var cityVar= getUrlParameter('city');
$('.city').html(cityVar);
</script>