I’m making an ajax request to call php file with variable. But it is not getting the value. I’ve called $("#data").load("myfile.php?filename=file.xml")
in myfile.php
$(window).load(function(){
$.ajax({
type: "GET",
url: "../files<?php echo $_GET['filename']; ?>",
dataType: "xml",
success: function(dataXML) {
XML = dataXML;
runNow();
}
});
But this two level ajax is request is not working. I’ve tried finding it with network debugger of browser, but this request is not made.
To simplify there is a page which is making the ajax request and loads its data to one div. That div has a <script> </script> . And inside it there is one another ajax request.
This second ajax request is not working and not getting the php variable value with $_GET['filename'].
I don’t believe a load event is called on
windowwhen the first AJAX call loads the new script element onto the page, so the inserted AJAX javascript is not being triggered.Try removing the
$(window).loadwrapper and just directly call$.ajax()