it’s redirecting… why?
-
What I’m doing is making the different sections in my sidebar collapsible. It would be working fine except that when my javascript calls sidebar_update.php to get the stuff it’s adding when they expand a section it doesn’t always return what’s actually in the file. Instead what it’s does the majority of the time is display the index.php as if I called a file that doesn’t exist and why it only does it some/most of the time doesn’t make sense.
Here is the content of “sidebar_update.php”
<?php require('wp-config.php') ; $pages_in=$_POST['pages_in']; if ($pages_in=="PR") { ?> <form method="post"><input type="hidden" id="pages_in" name="pages_in" value="PE" /></form> <h2 class="h2E" onclick="pages()"><?php _e('pages'); ?></h2> <ul class="SideLinksUL"> <?php wp_list_pages('title_li='); ?> </ul> <?php } else { echo "error"; }; ?>
Here is the javascript though I don’t think the problem is with it… PS: in the interest of saving a little space I left out most of the XMLHttpRequest detecting stuff out.
function pages() { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var pages_in=document.getElementById("pages_in"); var retract=('<form method="get"><input type="hidden" id="pages_in" name="pages_in" value="PR" /></form> <h2 class="h2R" onclick="pages()">pages</h2>'); if (pages_in.value=="PR") { var url="sidebar_update.php"; url=url+"&sid="+Math.random(); var params="pages_in=" + pages_in.value; xmlHttp.onreadystatechange=stateChangedS1; xmlHttp.open("POST",url,true); xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-Length", params.length); xmlHttp.send(params); } else if (pages_in.value=="PE") { document.getElementById("pages").innerHTML=retract; } } function stateChangedS1() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("pages").innerHTML=xmlHttp.responseText } }
Just so you know in the sidebar.php page under the theme folder I’m using “<script type=”text/javascript”></script>” to get the javascript from the main w-p directory since I can’t have the “sidebar_update.php” page in the theme folder.
- The topic ‘it’s redirecting… why?’ is closed to new replies.