So I've been looking through stackoverflow for similar problems / answers and gotten nowhere so I opened this new question in hopes someone can help me. Basically I have a HTML page and a Javascript page. All other functions are working except this specific one. I think the problem is something to do with reloading the DOM but I can't figure out the problem. I have this on my HTML:
<button id="advanced_search" onclick="query()">Advanced Search</button>
And I have this on my Script:
document.addEventListener("DOMContentLoaded", function(e)
{
....
....
....
// V Everything inside here is fine, if I put this in the html page inside
// V a <script></script> it works fine.
function query() {
...
...
...
if(add_and != 0){
//Im using cypher to query my neo4j database.
queryStr = "match (n)-[r]->(m) where " + add_and.join(" ")+ " return
n,r,m";
} else {
queryStr = 'match (n)-[r]->(m) return n,r,m';
}
}
// side problem: the queryStr doesn't change from function query to var jqxhr
var jqxhr = $.post(neo4jAPIURL, '{"statements":[{"statement":"' + queryStr + '", "resultDataContents":["graph"]}]}',
function(data) {
...
... // some d3.js stuff inside
...
}
My problem is that it says the function query() is not defined at HTMLButtonElement.onclick even though I'm calling the function:
<script src="/scripts/force_directed_layout.js"></script>
The expected result is when I press the <button id="advanced_search"> the function should run normally but this is not the case. If anyone could help me it would be wonderful.