last day (14 days later) » 

1:25 PM
0
A: How to use the same HTML page across multiple URLs except for the value of one variable depending upon URL queried?

KaiidoYou could look for the hash property of the window.location object : var hash = window.location.hash; var jsonOb = {}; if ( hash.indexOf('_') > 0 ) { var parts = hash.split('#')[1].split('_'); jsonOb[parts[0]]= parts[1]; } else { jsonOb = {'A':'A'}; } Now you would ju...

 
The jsonOb is a really really big object. Is this a feasible solution for that as well?
 
No. Sorry, I though you were getting an json with that var, not posting it
 
Any alternative approach for that?
 
But how much vary your objects? You could still use this and store every objects on a single page. Or even query for external json file with XHR
 
Could show the code snippet for querying the external json file via XHR?
 
1:25 PM
yep I'll edit the answer.
 
Thanks!
 
1:36 PM
updated
 
going through this
im very new to web dev
could you tell me where I should include this code snippet?
 
I'm not really familiar with angular but I would say inside the myApp.controller('DashboardDisplay', ['$scope','$http',function($scope,$http) {
 
and I should define my submit function within your code snippet, right?
and I should have different .json files for different values of my variable, right?
what does the xhr("get", ...) do?
*xhr.open("get",...)
 
you can read some infos about XMLHttpRequest here : developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
Yes you should insert the submit function inside the xhr response (where I left "... your function here")
 
one last question
where should I be storing the JSON files?
 
1:45 PM
Wherever you want, in the same domain as you html preferably, but you could create a folder for them, ten you will have to change the xhr.open("GET", "file"+jsonPage+".json", true);to xhr.open("GET", "your_folder/file"+jsonPage+".json", true);
 
thanks a lot!
i'll try that right now
:)
 

last day (14 days later) »