Autor Beitrag
Handycommander
ontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1054

Windows XP Pro, Vista
Visual Studio 2008
BeitragVerfasst: Sa 31.10.09 01:22 
Hi,

ich möchte gerne über einen Link einen <div>-Tag aktualisieren, damit ich nicht die komplette Seite neuladen muss.
Zwar hab ich bereits Beispiele gefunden, jedoch funktionieren die nicht.
Meine HTML-Site ist so in etwa aufgebaut:

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
<div id="content">
  <div id="divDetails">
    DIESES DIV-TAG SOLL AKTUALISIERT WERDEN!
  </div>
</div>
</div id="footer">
  <a href="#" onclick="dieFunktion()">Refresh</a>
</div>


Hat jemand ne Idee, wie ich das mit JavaScript machen kann?
Danke für eure Hilfe!

Gruß,
Tobi
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Sa 31.10.09 02:28 
Läuft die Aktualisierung über einen Server oder geht es erst einmal nur um die Client-Seite?
Auf jeden Fall würde ich selbst für solche Kleinigkeiten sofort zu jQuery o. Ä. raten, damit bist du mit
ausblenden C#-Quelltext
1:
$("divDetails").html("<b>aktualisiert!</b>");					

am Ziel.

_________________
>λ=
MDX
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 595
Erhaltene Danke: 4

Windows 8.1, Linux Debian 8, Android Lollipop
Delphi, PHP, Java (Android)
BeitragVerfasst: Sa 31.10.09 04:53 
Geht auch ganz einfach mit:

ausblenden C#-Quelltext
1:
2:
3:
function DieFunktion(){
document.getElementById('divDetails').innerHTML='<strong>Der neue Code</strong>';
}


@Kha: Man benutzt kein <b>-Tag mehr xD


Zuletzt bearbeitet von MDX am Sa 31.10.09 20:04, insgesamt 1-mal bearbeitet
Handycommander Threadstarter
ontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1054

Windows XP Pro, Vista
Visual Studio 2008
BeitragVerfasst: Sa 31.10.09 18:40 
Danke!
Funktionierte leider nicht :(
Hier mal der komplette Code:

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Unbenanntes Dokument</title>

<script language="javascript">
  <!--
  function DieFunktion(){
    document.getElementById('divDetails').innerHTML('<strong>Der neue Code</strong>');
  }
  -->

</script>

</head>

<body>
<div id="content">
  <div id="divDetails">
    DIESES DIV-TAG SOLL AKTUALISIERT WERDEN!
  </div>
</div>
</div id="footer">
  <a href="#" onclick="DieFunktion()">Refresh</a>
</div>
</body>
</html>


Hat jemand vll noch ne Idee? Mit jQuery hat es leider auch nicht geklappt...
Kann es vll damit zu tun haben, dass ich von einem anderen div-Tag aus aktualisieren möchte?

Gruß,
Tobi
jfheins
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 918
Erhaltene Danke: 158

Win 10
VS 2013, VS2015
BeitragVerfasst: Sa 31.10.09 18:44 
innerHTML ist auch keine Funktion sondern eine Eigenschaft: de.selfhtml.org/java...e/all.htm#inner_html
Handycommander Threadstarter
ontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1054

Windows XP Pro, Vista
Visual Studio 2008
BeitragVerfasst: Sa 31.10.09 18:52 
Ah, super!!
Jetzt klappts! Danke!

Gruß
Tobi
MDX
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 595
Erhaltene Danke: 4

Windows 8.1, Linux Debian 8, Android Lollipop
Delphi, PHP, Java (Android)
BeitragVerfasst: Sa 31.10.09 20:04 
Oh, sorry, war schon ein bisschen spät =D