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,99416 gold badges38 silver badges53 bronze badges
asked Jan 3, 2014 at 15:04
3
  • load is a jQuery function. I've not seen a native load function before (I could be wrong) Commented Jan 3, 2014 at 15:06
  • load function is a jQuery one, check out here Commented Jan 3, 2014 at 15:06
  • oh...is there a not jQuery function to do this? Commented Jan 3, 2014 at 15:07

1 Answer 1

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.

answered Jan 3, 2014 at 15:08
Sign up to request clarification or add additional context in comments.

8 Comments

.load kind of suggests jQuery
I don't think op wants jquery... my guess is he actually wants the ajax request.
i dont want to use Ajax or Jquery. Isnt there a normal way? So i have to reload the whole page?
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.
So i think i should do the reload, whick takes the speed-brake and load to the user-site, not the server.
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.