i want to load data from my php file into my jquery mobile page. I need to send data pageid(php variable) to my php file to run the query. I want to load the the content from my php file while loading #topics page in jquery from my topics file.
here is my onclick anchor:
$pageid = 1;
<a class="clickme" href="#topics_main_id" onClick="load_page(<?php echo $pageid;?">Content</a>
here is my script:
<script>
$( document ).on( "pageinit" function( event ) {
function load_page(id){
$.ajax({
type: "POST",
url: "topic01.php",
data: {
pageid: id
},
success: function(content) {
$("#thema").html(content);
}
});
return false;
}
});
</script>
here is my php file:
<?php
$pageid = $_POST["pageid"];
$abfrage = "SELECT * FROM topics WHERE id='$pageid'";
$ergebnis = $db->query($abfrage);
while($row = $ergebnis->fetch_assoc()){
$topic = $row["topic"];
}
?>
<span style="font-weight: bold; font-size: 13pt;">Thema</span><br> <span style="font-weight: normal;"><?php echo $topic; ?></span>
this #topics_main_id is a div content="page", that i want to get the html from my php file in. I want it to load into the span id="#thema" in my div container #topics_main_id
Can anyone help me please? i try to load this dynamically, is it possible?