dimanche 13 avril 2014

JavaScript - lien de base et recherche api - Stack Overflow


I am attempting to query a database through an API which I don't fully understand. I have been sent an example of the API being used with a keyword search form. The form is an html file and uses jquery return JSON documents, format items into an array array, and display.


I tried to build the design of my application and manipulate the form to work within my pages. The file the uses the API requires that the a base link be used.


<base href="{{app_root}}">

If I remove this base link my functionality of the search is lost. If I use the base link all of presentation and CSS is lost.


I thought maybe I could change the base link dynamically when I needed to call the search file with:


<script type="text/javascript"> 
function setbasehref(basehref) {
var thebase = document.getElementsByTagName("base");
thebase[0].href = basehref;
}
//setbasehref("{{app_root}}");
setbasehref("{{app_root}}");
</script>

Then use setbasehref() to change it back to my original base link, but that didn't work.


I'm new to javascript and JSON, and I'm not entirely sure what app_root is doing. Any thoughts?



I am attempting to query a database through an API which I don't fully understand. I have been sent an example of the API being used with a keyword search form. The form is an html file and uses jquery return JSON documents, format items into an array array, and display.


I tried to build the design of my application and manipulate the form to work within my pages. The file the uses the API requires that the a base link be used.


<base href="{{app_root}}">

If I remove this base link my functionality of the search is lost. If I use the base link all of presentation and CSS is lost.


I thought maybe I could change the base link dynamically when I needed to call the search file with:


<script type="text/javascript"> 
function setbasehref(basehref) {
var thebase = document.getElementsByTagName("base");
thebase[0].href = basehref;
}
//setbasehref("{{app_root}}");
setbasehref("{{app_root}}");
</script>

Then use setbasehref() to change it back to my original base link, but that didn't work.


I'm new to javascript and JSON, and I'm not entirely sure what app_root is doing. Any thoughts?


0 commentaires:

Enregistrer un commentaire