EDIT: The question has more to do with altering the variable (valueA) than anything. I am already getting the desired load result using the script below. I am trying to attach something to the script that will ultimately alter valueA once clicked.
I am designing multiple pages that will load into a main content div on click using .load
index.php
//Setting default value
$valueA = 5;
//Created separate div to allow me to monitor the variable and changes
<div><?php echo $valueA; ?></div>
//Loading first page into div
<div id=main_content>
<?php include 'page1.php'; ?>
</div>
Included in page1.php is a button that will load the page assigned to it.
page1.php
<button id="button1">Click Me!</button>
<script>
$(document).ready(function(){
$('#button1').click(function(){
$('#main_content').load('page2.php').hide().fadeIn('slow');
$.ajax({
type: 'POST',
url: 'index.php',
success: $valueA += 5,
});
});
})
Upon clicking, page2.php will load, but the value will remain 5. I am trying to figure out how to add the 5 using the ajax script to the valueA. Ultimately, the new page would load, and the value would increase to 10.
success: $valueA += 5,is invalid you couldn't mix PHP and JS like that.