I have a page containing all the usual elements (html/php, css, js) and from within it I call (using a form) a page via ajax. All that works just fine and I'm happy with that...EXCEPT it's somehow not completing!
The ajax call is:
$( ".view_button" ).click(function( event ) {
$( "#reportframe" ).html( "Loading...");
var geturl = $( "#holder" ).attr("action");
$.ajax({
url: geturl,
type: 'get',
dataType: 'html',
async: false,
data: $('#holder').serialize()
})
.done(function(html) {
$( "#reportframe" ).html(html);
alert("Loaded!");
});
});
.view_button is the form's submit button, #holder is the form id and #reportframe is div into which the page is loaded. The reason geturl is set is because depending on the options selected in the form it will change the 'action' attribute of the form to get a different page.
There are two things that I can't seem to resolve:
The first time the page is loaded via ajax the 'alert' does not show and most jquery elements do not work. HOWEVER, the second (and subsequent) time the page is loaded via ajax the 'alert' pops up on completion and SOME of the jquery elements work!
Getting ALL jquery to work in the loaded page! Specifically there's a tool we load called 'tooltipster' - this clearly doesn't get added in because console says 'tooltipster is not a function', even though the js file is called and loaded.
All js/jquery code and files are called at the end of the loaded page.
One more thing - I can't seem to grab data to display it even though it clearly gets transmitted in the ajax. Any ideas?
Any insights VERY gratefully received!!