Smashden Posted October 5, 2015 Share Posted October 5, 2015 (edited) Hello, I have a script which makes that when you click on <li> shows include PHP in DIV(load after the page loads). I want to include PHP file when I click and show it. Look at me code: <ul class="task-menu" style="width: 200px;"> <li class="account_buttons" data-target=".option1">Create Character</li> <li class="account_buttons" data-target=".option2">Delete Character</li> <li class="account_buttons" data-target=".option3">Change Password</li> <li class="account_buttons" data-target=".option4">Change Email</li> <li class="account_buttons" data-target=".option5">Create Guild</li> </ul> <script> $(document).ready(function () { var $targets = $('.target'); $('.task-menu .account_buttons').click(function () { var $target = $($(this).data('target')).toggle(600); $targets.not($target).hide(800) }); }); </script> This I have on botttom my page: <div class="option1 target" style="display: none;"> <hr class="account_edit"> <?php include ("modules/option1.php"); ?> -- here I want to include when I click on option1 <script src="javascript/option1_script.js"></script> </div> <div class="option2 target" style="display: none;"> <hr class="account_edit"> <?php include ("modules/option2.php"); ?> -- here I want to include when I click on option2 <script src="javascript/option2_script.js"></script> </div> <div class="option3 target" style="display: none;"> <hr class="account_edit"> <?php include ("modules/option3.php"); ?> -- here I want to include when I click on option2 <script src="javascript/option3_script.js"></script> </div> <div class="option4 target" style="display: none;"> <hr class="account_edit"> <?php include ("modules/option4.php"); ?> -- here I want to include when I click on option2 <script src="javascript/option4_script.js"></script> </div> <div class="option5 target" style="display: none;"> <hr class="account_edit"> <?php include ("modules/option5.php"); ?> -- here I want to include when I click on option2 <script src="javascript/option5_script.js"></script> </div> Edited October 5, 2015 by Smashden Quote Link to comment https://forums.phpfreaks.com/topic/298436-after-click-include-php-file-to-div/ Share on other sites More sharing options...
scootstah Posted October 5, 2015 Share Posted October 5, 2015 You can't "include" PHP from Javascript - the PHP has already finished executing by the time the Javascript is even sent to the browser. You will have to use AJAX requests to fetch content from PHP scripts. 1 Quote Link to comment https://forums.phpfreaks.com/topic/298436-after-click-include-php-file-to-div/#findComment-1522364 Share on other sites More sharing options...
Smashden Posted October 5, 2015 Author Share Posted October 5, 2015 Oh, I thought that JS can do it. Can you move topic to AJAX Help? Quote Link to comment https://forums.phpfreaks.com/topic/298436-after-click-include-php-file-to-div/#findComment-1522374 Share on other sites More sharing options...
cyberRobot Posted October 6, 2015 Share Posted October 6, 2015 Oh, I thought that JS can do it. Can you move topic to AJAX Help? The topic has been moved. Quote Link to comment https://forums.phpfreaks.com/topic/298436-after-click-include-php-file-to-div/#findComment-1522469 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.