How can I send post data after loading a page with jQuery?
For example
$( "#target" ).click(function() {
$('#thetag').load(page.php, function(){
$.ajax({
type: "POST",
url: "page.php",
data: {data: "hi world"},
success: function(result) {
console.log('good');
}
});
});
});
</div id="thetag">
page.php
<?php echo $_POST['data'] ?> ==== 'hi world'
</div>
I need to load the page.php
file after the click on #target
and, at the same time, send that data via ajax post; showing the post data in #thetag