cordoprod Posted February 7, 2009 Share Posted February 7, 2009 Hi. I have a page, and i want to make a tabbed panel kind of. But i want ajax, to load the page in the content. But the problem is, i include a lot of pages, and when i load the page in the content, they disappear. ajax.js: function ahah(url, target) { document.getElementById(target).innerHTML = ' <img src=\"img/icon/square-loader.gif\" title=\"Laster innhold...\" />'; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req != undefined) { req.onreadystatechange = function() {ahahDone(url, target);}; req.open("GET", url, true); req.send(""); } } function ahahDone(url, target) { if (req.readyState == 4) { // only if req is "loaded" if (req.status == 200) { // only if "OK" document.getElementById(target).innerHTML = req.responseText; } else { document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText; } } } function load(name, div) { ahah(name,div); return false; } the page where the panel is: <?PHP head("stage/Settings", "Innstillinger"); ?> <table width="98%" border="0" cellspacing="1" cellpadding="2"> <tr> <td><div class="menybar" align=center> <ul> <li><a href="user.php" onclick="load('user.php','content');return false;">Profiltekst</a></li> <li><a href="user.php" onclick="load('user.php','content');return false;">Brukerkonto</a></li> <li><a href="profilbilde.php" onclick="load('inc/sider/profilbilde.php','content');return false;">Profilbilde</a></li> <li><a href="user.php" onclick="load('user.php','content');return false;">Svarteliste</a></li> <li><a href="user.php" onclick="load('user.php','content');return false;">Slett konto</a></li> </ul> </div></td> </tr> <tr> <td style="padding-left: 15px; padding-top: 5px;"><span id="content"></span></td> </tr> </table> profilbilde.php <?PHP include("../func/connect.php"); include("../func/profil.php"); include("../func/design.php"); include("../func/general.php"); include("../func/image.php"); ?> <table width="98%" border="0" cellspacing="0" cellpadding="3"> <tr> <td class="header"><?PHP smallinfo("Her kan du endre ditt profilbilde.<br>Støttede bildeformater: jpg, gif, png"); ?></td> </tr> <tr> <td valign="top"><?PHP if($_GET['action'] == "upload") { $uploadedfile = $_FILES['uploadedfile']['tmp_name']; $uploadedfile2 = $_FILES['uploadedfile']['name']; $type = explode(".", $uploadedfile2); if($type[1] == "png" or $type[1] == "gif" or $type[1] == "jpg") { CropImage(640, 480, $uploadedfile, $type[1], "img/profil/".$_SESSION['username'].".jpg", 80); CropImage(160, 196, $uploadedfile, $type[1], "img/profil/".$_SESSION['username']."_medium.jpg", 80); CropImage(60, 74, $uploadedfile, $type[1], "img/profil/".$_SESSION['username']."_tiny.jpg", 80); header("Location: ?s=profilbilde"); } else echo "<div>Det skjedde en feil ved opplastning av profilbildet.<br>Se over at profilbildet stemmer overens med kravene.<br><br>Gjeldene format: {$type[1]}<br>Støttede formater: jpg, gif, png</div>"; } elseif($_GET['action'] == "slett") { unlink("img/profil/".$_SESSION['username']."_medium.jpg"); unlink("img/profil/".$_SESSION['username']."_tiny.jpg"); unlink("img/profil/".$_SESSION['username'].".jpg"); header("Location: ?s=profilbilde"); } else {?> <table width="118%" border="0" cellspacing="0" cellpadding="2"> <tr> <td colspan="2"><b>Ditt profilbilde</b></td> </tr> <?PHP if(file_exists("img/profil/".$_SESSION['username']."_tiny.jpg") && file_exists("img/profil/".$_SESSION['username'].".jpg")) { ?> <tr> <td width="27%"><img src="img/profil/<?PHP echo $_SESSION['username']; ?>.jpg" width="360" height="270" /></td> <td width="73%" valign="bottom"><img src="img/profil/<?PHP echo $_SESSION['username']; ?>_medium.jpg" /> <img src="img/profil/<?PHP echo $_SESSION['username']; ?>_tiny.jpg" /></td> </tr> <? } else echo "<tr><td>Du har ikke lastet opp profilbilde enda.</td></tr>"; ?> </table> <br /> <table width="90%" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="34%"><b>Last opp</b></td> </tr> <tr> <td><form enctype="multipart/form-data" action="?s=profilbilde&action=upload" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="2097152" /> Bilde:<br /> <input name="uploadedfile" type="file" /> <br /> <input name="submit2" type="submit" id="submit2" value="Last opp bilde" /> </form></td> </tr> </table> <br /> <table width="90%" border="0" cellspacing="0" cellpadding="2"> <tr> <td><b>Fjern bilde</b></td> </tr> <tr> <td><form action="?s=profilbilde&action=slett" method="get"> <input name="s" type="hidden" value="profilbilde" /> <input name="action" type="hidden" value="slett" /> <input name="submit" type="submit" id="submit" value="Fjern bilde" /> </form></td> </tr> </table> <br /> <? } ?></td> </tr> </table> ask me if i'm uncertain Link to comment https://forums.phpfreaks.com/topic/144197-php-and-ajax-help/ Share on other sites More sharing options...
cordoprod Posted February 7, 2009 Author Share Posted February 7, 2009 Anyone got a clue? Link to comment https://forums.phpfreaks.com/topic/144197-php-and-ajax-help/#findComment-756738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.