Changing a url depending on what link chosen (HTML) no asp.
Posted
by Ozaki
on Stack Overflow
See other posts from Stack Overflow
or by Ozaki
Published on 2010-05-03T01:43:51Z
Indexed on
2010/05/03
1:48 UTC
Read the original article
Hit count: 289
TLDR I need to change a javascript variable on the same page after clicking a link (can be from a different page) so that the getjson request pulls different data without having to duplicate on html pages.
I am using some getJSON requests with Jquery, to make calls to populate my pages. I want to be able to (in plain HTML / javascript) when the user clicks say "link 1" or "link 2" to open the same page (say page.html) but change the get request url to "link 1" or "link 2".
Page.html
var url = ??;
$.getJSON(url, function(data){}
link 1
var url = host/link1
<a href="page.html">link1</a>
link2
var url = host/link2
<a href="page.html">link2</a>
So I call the same page but am able to populate it with different content. Purposely staying away from asp. Was thinking maybe of inserting the content into a div after page load so the url can be set or something along those lines.
Any ideas how I might go about this?
© Stack Overflow or respective owner