JudeJitsu JudeJitsu - 6 months ago 166
Javascript Question

How to load PHP file into DIV by jQuery?

I am developing a website and I have this on the side menu :

<a href="#" class="leftMenu" id="contact">Contact Us</a>


then I have this script

$(document).ready(function(){
$("#contact").click(function(){
$("#contents").load('home.php');
});
});


and I have this DIV inside my page :

<div class="contentWrapper" id="contents"></div>


Obviously, what I am trying to do is to load home.php when I click on the Contact Us hyperlink, which doesn't work. What is wrong with my code?

Answer

add home.php page url instead of file name.

$(document).ready(function(){
  $("#contact").click(function(){
    $("#contents").load('url to home.php');
  });
});
Comments