Reputation: 714
I need to load the JS and CSS before the Ajax page HTML render. here's the scenario:
1.PHP
content below code - Basically it call the ajax :<script> $('#loading_spinner').show(); var mydata = 105; var post_data = "isln="+mydata; $.ajax({ url: 'processpage.php', type: 'POST', data: post_data, dataType: 'html', success: function(data) { $('.my_update_panel').html(data); $('#loading_spinner').hide(); }, error: function() { alert("Something went wrong!"); } }); </script>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Brand Management</title> <link rel=stylesheet type=text/css href='css/1.css'/> <link rel=stylesheet type=text/css href='css/2.css'/> <link rel=stylesheet type=text/css href='css/3.css'/> <link rel=stylesheet type=text/css href='css/4.css'/> <script type='text/javascript' src='js/jquery-1.11.2.min.js'></script> <script type='text/javascript' src='js/jquery-ui.min.js'></script> <script type='text/javascript' src='js/scripts.js'></script> <script type='text/javascript' src='js/mh-overlay.js'></script> <script type='text/javascript' src='js/jquery.qtip.min.js'></script> </head> <?php echo "My PHP CODE Process"; ?>
Issue: when i load the pages it first execute my PHP code and after that it load all CSS and JS. but i want to load all JS and then load PHP code output
Currently It Loads :
PHP Code Output
JS1
JS2
I want it must be:
JS1
JS2
PHP Code Output
PS: I already tried with the ajax.load()
and other available answer of this site , but it couldn't work!!!
Thanks in Advance!!!
Upvotes: 0
Views: 536
Reputation: 19182
What you're asking is impossible. PHP code is executed by the server before the response, including the javascript code and css, is even sent to the client. You'll need several ajax queries to achieve what you're trying to.
Upvotes: 1