dystopia
dystopia

Reputation: 93

jQuery/Ajax to dynamically load a specific id PHP page

I'm relatively new to jQuery/Ajax and I was wondering what would be the best way of loading via jQuery/AJAX a php page with an ID attached to it.

obviously

<?php $id = $_SESSION[id]; ?>
<script>
var pageUrl = new Array(); 
pageUrl[1] = "tab1.html?id=<php echo $id;?>"; 
.....
</script>

makes no sense.

What would be the best way of going about this? Thank you!

Upvotes: 3

Views: 473

Answers (1)

Jonas m
Jonas m

Reputation: 2734

Use jQuery's $.get command and send parameters with it.

$.get("tab1.html", { id: <?php echo $id; ?> },
  function(data){
    alert("Output goes into the variable data: " + data);
  });

Upvotes: 1

Related Questions