1

My site has a one <div> for the header, one for navigation-panel and one for the content.

For the navigation-links i use

<p class="blue"><label onclick="goFor('test')"> -> TEST! <- </label> </p>

and my JS:

function goFor(destination) 
{ 
    document.getElementById("content").load(destination+'.php'); 
}

in this case, the content-div should change to the file "test.php".

but Firebug says: document.getElementById(...).load is not a function

what am i doing wrong?

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
HKK
  • 237
  • 1
  • 3
  • 17

1 Answers1

3

Use $("#content").load(something) instead of document.getElementById.

Or... make an ajax request and load answer in that div.

For an ajax request with no lib, you can check my script here (first answer): Insert external page html into a page html. Note the success handle as you want it... with document.getElementById.

Community
  • 1
  • 1
zozo
  • 8,230
  • 19
  • 79
  • 134
  • .load kind of suggests jQuery – Lex Podgorny Jan 03 '14 at 15:09
  • I don't think op wants jquery... my guess is he actually wants the ajax request. – zozo Jan 03 '14 at 15:10
  • i dont want to use Ajax or Jquery. Isnt there a normal way? So i have to reload the whole page? – HKK Jan 03 '14 at 15:13
  • If your file is .php, and you want it parsed... you have 2 choices: ajax or reload. If your file is something else... depends. Also... why you don't want ajax? You do know that a reload makes the same request you would do by ajax. – zozo Jan 03 '14 at 15:14
  • So i think i should do the reload, whick takes the speed-brake and load to the user-site, not the server. – HKK Jan 03 '14 at 15:15
  • Anything you do to get a .php will load the server. .php is parsed on server. Also at reload you make a request... is how http works. – zozo Jan 03 '14 at 15:16
  • really?..why is the time to re-load about 3 secs, and the Ajax about 8.5 sec's (measured by Firefox) – HKK Jan 03 '14 at 15:17
  • Cache. You can also cache the ajax. Clear cache, press f5, you'll get 8.5 sec. Cache the ajax, you'll get the 3 sec. – zozo Jan 03 '14 at 15:17