I am having a problem. i have some code that i need to use ajax to bring up results when a specific link is clicked. it gets the id of the button anduses ajax to search the database for that id. At the moment i am able to post to the next page but i need to load the results at the same time so as it posts to the page say if that page had a confirmation it would show on the index page.
index.php
<script type="text/javascript" src="jquery.min.js"></script>
<button class="Stylebut" style="background-color:yellow;" id="500" onClick="reply_click(this.id)">time</button>
<script type="text/javascript">
function reply_click(clicked_id)
{
$.ajax({
url: 'load.php', //This is the current doc
type: "POST",
dataType:'json', // add json datatype to get json
data: ({name: clicked_id}),
success: function(data){
console.log(data);
alert("hello")
}
});
}
</script>
load.php
<?php
$userAnswer = $_POST['name'];
?>
<p>This text needs to show on the page and anything else that loads up</p>
i need to send the data to the page and load that page using the data and print it on the first page using ajax. thanks for your help