Expand|Select|Wrap|Line Numbers
- //logout.php
- <?php
- if (!session_start());
- session_destroy(); //Destroys the session
- echo "success";
- ?>
Expand|Select|Wrap|Line Numbers
- //erroneous file
- var httpobj = null;
- function dothis()
- {
- }
- // Get the HTTP Object
- function obje(){
- if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
- else if (window.XMLHttpRequest) return new XMLHttpRequest();
- else {
- alert("Your browser does not support AJAX.");
- return null;
- }
- }
- // Change the value of the outputText field
- function setthis(obj,link){
- if(httpobj.readyState == 4){
- if (httpobj.responseText=="success")
- {
- document.getElementById(obj).innerHTML = "<a href='page.php?type=login' class='"+link+"'>Login</a> | <a href='page.php?type=register' class='"+link+"'>Register</a>";
- } else {
- alert("Failed to log out!!!");
- }
- }}
- // Implement business logic
- function logout(obj,link){
- httpobj = obje();
- if (httpobj != null) {
- var parameters = "nothing=nothing";
- httpobj.open("GET", "ajax/logout.php", true);
- httpobj.send(parameters);
- httpobj.onreadystatechange = setthis(obj,link); //The ill-fated line 32.
- }}
Expand|Select|Wrap|Line Numbers
- var httpobj = null;
- function dothis()
- {
- }
- // Get the HTTP Object
- function obje(){
- if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
- else if (window.XMLHttpRequest) return new XMLHttpRequest();
- else {
- alert("Your browser does not support AJAX.");
- return null;
- }
- }
- // Change the value of the outputText field
- function setthis(obj,link){
- if(httpobj.readyState == 4){
- if (httpobj.responseText=="success")
- {
- document.getElementById(obj).innerHTML = "<a href='page.php?type=login' class='"+link+"'>Login</a> | <a href='page.php?type=register' class='"+link+"'>Register</a>";
- } else {
- alert("Failed to log out!!!");
- }
- }}
- // Implement business logic
- function logout(obj,link){
- httpobj = obje();
- if (httpobj != null) {
- var parameters = "nothing=nothing";
- httpobj.open("GET", "ajax/logout.php", true);
- httpobj.send(parameters);
- alert();//The annoying little prompt.
- httpobj.onreadystatechange = setthis(obj,link);//The ill-fated line 32.
- }}
Basically what I'm tryin to have it do is when it is clicked, it passes its id and the id of it's parent node to a function which terminates the session and then changes the innerHTML of the parent node to a different link (a log in link - since they just logged out) which has the same css as the clicked link.
That's a mouthful, but it should be pretty simple. I've quintuple-checked this script and I can't find any errors or any reason for calling alert() to make it work.
Let me know what you figure out.
Gradinafrica