Jump to content

After click include PHP file to DIV.


Smashden

Recommended Posts

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>	
Link to post
Share on other sites

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.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.