0

I have gone through this Link here at stackoverflow, but I cant seem to get the div loaded here is my code

<div id="leftmenu" style="font-size:20px;position:absolute;top:12%;bottom:0;right:0;left:2%;">
                <a href="#" id="details"> Form </a>
</div>

<div id="content" style="font-size:20px;position:absolute;top:12%;bottom:0;right:10%;left:12%;">
</div>

<script>
          $(document).ready(function(){
            $("#details").click(function(){
                $("#content").load('student_details.php');
            });
          });
</script>

Edit: Made change to Load part but still does not work for me

Edit 2:

<!DOCTYPE html>
<html>
    <head>
       <title> test </title> 
       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
       </script>
    </head>
    <body>
        <div id="leftmenu" style="font-size:20px;position:absolute;top:12%;bottom:0;right:0;left:2%;width:100px;height:100px;">
                <a href="#" id="details"> Form </a>
        </div>

        <div id="content" style="font-size:20px;position:absolute;top:12%;bottom:0;right:10%;left:12%;">
        </div>
        <script>
          $(document).ready(function(){
            $("#details").click(function(){
                $("#content").load('load.html');
            });
          });
        </script>
    </body>
</html>

The following code also fails to work the load.html file is present in D: drive have I done something wrong in div? or maybe the script tag?

the content of load.html is " this works "

Community
  • 1
  • 1
AAB
  • 1,594
  • 2
  • 25
  • 40
  • 1
    `$("#content").load('student_details.php');` – Arun P Johny Dec 24 '13 at 06:41
  • check if given url is valid! – Nitin Varpe Dec 24 '13 at 06:41
  • Hi,i have tried that no luck – AAB Dec 24 '13 at 06:42
  • try using full url instead. $("#content").load('site.com/something/student_details.php'); – nik Dec 24 '13 at 06:45
  • Does your `
    ` have any size on screen that gives it the ability to be clicked?? If the div's width/height are `0px` it will be kind of hard to click on it. Use your browsers developer tools to verify this.
    – Crackertastic Dec 24 '13 at 06:46
  • Hi, "./student_details.php" and localhost/Practice/student_details.php both not working – AAB Dec 24 '13 at 06:47
  • @ Crackertastic 42px x 22px – AAB Dec 24 '13 at 06:50
  • @Crackertastic the .php page has only – AAB Dec 24 '13 at 06:54
  • Does executing `student_details.php` by itself produce an error? Also, if an error is occurring and errors are being suppressed, that may be part of your problem. One thing that I could point out is the lack of a semicolon in your `echo` statement, per your comment above. `` should be `` – Crackertastic Dec 24 '13 at 07:02
  • Hi, Errors are not suppressed. I forgot type the semicolon in above comment.I will first try loading the above for a simple html page.Let me see if that works. – AAB Dec 24 '13 at 07:12

2 Answers2

2

The url has to be passed as an string literal enclosed within '' or ""

$("#content").load('student_details.php');
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
2

The file path has to be a string. So instead of:

$("#content").load(student_details.php);

You would put:

$("#content").load("student_details.php");
Drummss
  • 45
  • 7