When this function is ran, results.php
does not get loaded. I have tested to see if the function itself is even called, and it is (as “hello1” gets alerted). However, for some reason, the contents of results.php are not getting loaded into the correct section.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function loadTable(){
alert("hello1");
$("#results_page").load("results.php");
}
</script>
<div id="results_page"></div>
Here are the contents of results.php
. (I used an alert("Hello2")
to check if it gets loaded, and hello2 does not get alerted so I am assuming the page does not get loaded.
<html>
<script type="text/javascript">
alert("hello2");
</script>
</html>
It thus seems the issue lies with the following statement in wedding.php
(the original document)
$("#results_page").load("results.php");
Any ideas?
EDIT:
loadTable()
gets called in a seperate function which too is loaded. Here is a more detailed version of what the main program (wedding.php
) looks like.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#form_details").load('form.php');
});
function loadTable(){
alert($("#results_page").length);
$("#results_page").load("results.php");
}
</script>
<div id="form_details"></div>
<div id="results_page"></div>
So upon execution, form.php
gets loaded. This file contains a form which gets filled in. Once the form is submitted, a function called load()
gets called which calls loadTable().
Here is what form.php
looks like.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function load(){
alert("hello");
loadTable();
}
form.php
also contains a form, however to keep things concise I have not included it.
When testing, hello gets alerted, and therefore i believe load()
is correctly executed. Hello1 also gets alerted, and therefore i believe loadTable()
is correctly executed
2
Answers
add run of function loadTable() like this:
EDIT:
file: index.php:
file results.php:
All worked fine.
alert(“hell1”) -> alerted
alert(“hello2”) -> alerted
EDIT: Try #2.
I have created what I think is a replica. Three html pages.
main.html – On page load, loads form.html
form.html – Click the button and it calls main.html function loadResult()
result.html – has the result info
main.html
form.html
result.html