Jump to content

Recommended Posts

Hello, I have a script in JS 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. How can I do it in AJAX? 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>	
Link to comment
https://forums.phpfreaks.com/topic/298454-after-click-include-php-file-to-div/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.