Sorry silly question. Is it possible to load a page based on an AJAX post?
What I'm trying to do is have tabs on my page, with each tab containing different dynamic content updated by user posts.
So for example if Tab 1 is clicked I want it to show the posts associated with Tab 1, the same for Tab 2 and so on. I am not at all sure how best to achieve this.
I was thinking an onlcick event which send the Tab id to the relevant php file and then returns the results from that file based on the id. Please point me in the direction of a better approach as I'm sure this isn't the best way.
Please see code below:
index:
$(document).ready(function() {
var id = 1;
var DATA = '&id=' +id;
$.ajax({
type: "POST",
url: "show.php",
data: DATA,
cache: false,
success: function(data){
$(".test").load("show.php");
}
});
</script>
</head>
<body>
<div class="test"></div>
</body>
</html>
show.php:
<?php
$id = $_POST['id'];
$me = mysql_query("SELECT * FROM table where id=$id");
while($row=mysql_fetch_array($me)){
$status=$row['status'];
echo $status;
}
?>