MizziPizzi MizziPizzi - 6 months ago 9
Ajax Question

filling div using ajax?

I've recently created a website with a menu-bar to the left. My next step is to update the right side of the page with content based on what option you choose on the in the menu. I know you can use iframe but I was wondering if there is an alternative to it, like a more dynamic one!

Most of the menu options are input-forms, I've read about ajax-calls to fill a div but couldn't find a good tutorial on how to achieve it.

edit:

Here's a sketch http://imageshack.us/photo/my-images/16/smlithis.png/

Answer

You can use jQuery This is how your menu button will look like:

<a href='#' onclick='return fillDiv(1)'>GoTo1</a>  
<script>  
function fillDiv(pageNum){
  $("#id_of_div_to_load_to").load("some_page.php",{ 'pahe_num': pageNum } );  
return false;  
}
</script>

It is just one of many ways to do it.