I start my app with a listview of several states that have links like this:
example: <li><a href="#two?st=AZ">Arizona</a><li>
My second view (or page) should be populating my div id's for:
<div id="title"></div>
<div id="img"></div>
with this ajax code:
It will populate the view if I click refresh on the browser, but how do I get this done without having to do a physical refresh each time?
Thanks,
Pete
example: <li><a href="#two?st=AZ">Arizona</a><li>
My second view (or page) should be populating my div id's for:
<div id="title"></div>
<div id="img"></div>
with this ajax code:
function
getUrlVars() {<br>
var
vars = [], hash;<br>
var
hashes = window.location.href.slice(window.location.href.indexOf(
'?'
) + 1).split(
'&'
);<br>
for
(
var
i = 0; i < hashes.length; i++)<br>
{<br>
hash = hashes[i].split(
'='
);<br>
vars.push(hash[0]);<br>
vars[hash[0]] = hash[1];<br>
}<br>
return
vars;<br>
} <br>
<br>
var
st = getUrlVars()[
"st"
];<br>
<br>
<br>
$(document).ready(
function
(){<br>
$.ajax({<br>
url:
'http://staging.lifecaremediacenter.com/json/states.php?st='
+ st,<br>
method:
'GET'
,<br>
dataType:
'jsonp'
,<br>
success:
function
(data){<br>
$.each(data,
function
(){<br>
$(
'#title'
).text(
this
.stname);<br>
$(
'#img'
).attr(
'src'
,
'images/states/lrg/'
+
this
.img);<br>
}) <br>
} <br>
});<br>
});
It will populate the view if I click refresh on the browser, but how do I get this done without having to do a physical refresh each time?
Thanks,
Pete