Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: URGENT: Javascript / DICKBUTT Woes....  (Read 2062 times)

0 Members and 1 Guest are viewing this topic.

Xiphirx

wat
URGENT: Javascript / DICKBUTT Woes....
« on: August 23, 2008, 11:38:00 pm »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007

Code: [Select]
var lastpage = "notset";

function DICKBUTT()
{
var request;
try {
request = new XMLHttpRequest();
}
catch (n)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (n2)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (n3)
{
alert("Your Browser does not support DICKBUTT, which is needed to view this website. Please upgrade to the latest version of your favorite browser.");
window.location = "../Index.php";
return false;
}
}
}
return request;
}

function updatePage(location)
{
if (thing.readyState == 4)
{
if (thing.status !== 200)
{
document.getElementById(location).innerHTML = "Error, "+thing.status+"";
}
else
{
document.getElementById(location).innerHTML = thing.responseText;
}
}
}

function GetContent(url, method, place)
{
switch (method){
case "GET":
var kl = window.location.href.indexOf("?",0);
lastpage = window.location.href.substr(kl);
document.getElementById(place).innerHTML = "<center>Loading, please wait...<br /><img src='../gif/load.gif' /></center>";
thing = new DICKBUTT();
thing.open("GET", url, true);
thing.onreadystatechange = updatePage(place);
thing.send(null);
lastpage = GetDo();
break;
case "POST":
document.getElementById(place).innerHTML = "<center>Your request is being processed, please wait...<br /><img src='../gif/load.gif' /></center>";
thing = new DICKBUTT();
thing.open("POST", to, true);
thing.setRequestHeader("Content-type", "applicationx-www-form-urlencoded");
thing.setRequestHeader("Content-length", params.length);
thing.setRequestHeader("Connection", "close");
thing.onreadystatechange = updatePage(place);
thing.send(params);
break;
}
}

function GetDo()
{
var loc = window.location.href;
var idx = loc.indexOf("?", 0);
var stn = loc.substr(idx);
return stn;
}

function CheckDo()
{
if (GetDo().length > 1 && GetDo() != lastpage)
{
lastpage = GetDo();
GetContent("maincontent.php"+GetDo(), "GET", "here");
return true;
}
return false;
}

function INI()
{
if (CheckDo() == false)
{
GetContent("maincontent.php?do=home", "GET", "here");
}
}

The Problem?

Suddenly, my DICKBUTT is not working at all!. I am SURE something is wrong with updatePage(); because it stops execution when it is called...

EDIT: Updated : (

Here is what JSlint.com says

Error:

Implied global: ActiveXObject 13, XMLHttpRequest 7, alert 23, document 38 53, params 65, thing 34 54, to 63, window 24 51 75

EDIT: updated..

Please help, I need to finish this website in under a week!
Logged
  • For The Swarm
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #1 on: August 23, 2008, 11:41:33 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
'thing' is a local variable within GetContent, you can't use it outside of GetContent, as you are doing in updatePage.

Bit of advice, when you run it in firefox go to Tools->Error Console, that should give you a description of what went wrong during execution.
Logged

Xiphirx

wat
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #2 on: August 23, 2008, 11:44:18 pm »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
'thing' is a local variable within GetContent, you can't use it outside of GetContent, as you are doing in updatePage.

Bit of advice, when you run it in firefox go to Tools->Error Console, that should give you a description of what went wrong during execution.

Wow, really. I dont know why it worked before then O_o.

Anyway, there is nothing that appears in the console...

Let me try something and get back...

EDIT: So I tried to declare thing at the top of the js file

"var thing;"

still not working : /
« Last Edit: August 23, 2008, 11:55:46 pm by Xiphirx »
Logged
  • For The Swarm
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #3 on: August 23, 2008, 11:58:05 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Have you got it hosted somewhere? I'll have a look at it if I get the chance.
Logged

Xiphirx

wat
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #4 on: August 24, 2008, 12:02:55 am »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
Have you got it hosted somewhere? I'll have a look at it if I get the chance.

no I am developing locally
Logged
  • For The Swarm

Xiphirx

wat
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #5 on: August 24, 2008, 12:24:51 am »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
UPDATE:

I added manual debugging to the script. What I get is that it executes updatePage, then it continues.
I basically changed

thing.send(null);

to

thing.send(null);  document.getElementById(place).innerHTML = "send";

And "send" appears!, WTH!
Logged
  • For The Swarm
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #6 on: August 24, 2008, 01:05:14 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
lol, I totally missed the error, I'm quite suprised at myself, its an obvious one at that;

Code: [Select]
thing.onreadystatechange = updatePage(place);
OnReadyStateChange is a function pointer that takes 0 arguments. You need to set it to a function. At the moment all you are doing is setting it to the return value of updatePage, which is going to be null. To fix, do something like this;

Something like this should work (not tested);

Code: [Select]
var lastpage = "notset";
var glb_location = "";
var thing = null;

function DICKBUTT()
{
var request;
try {
request = new XMLHttpRequest();
}
catch (n)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (n2)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (n3)
{
alert("Your Browser does not support DICKBUTT, which is needed to view this website. Please upgrade to the latest version of your favorite browser.");
window.location = "../Index.php";
return false;
}
}
}
return request;
}

function updatePage()
{
        var location = glb_location;
if (thing.readyState == 4)
{
if (thing.status !== 200)
{
document.getElementById(location).innerHTML = "Error, "+thing.status+"";
}
else
{
document.getElementById(location).innerHTML = thing.responseText;
}
}
}

function GetContent(url, method, place)
{
switch (method){
case "GET":
var kl = window.location.href.indexOf("?",0);
lastpage = window.location.href.substr(kl);
document.getElementById(place).innerHTML = "<center>Loading, please wait...<br /><img src='../gif/load.gif' /></center>";
thing = new DICKBUTT();
thing.open("GET", url, true);
                glb_location = place;
thing.onreadystatechange = updatePage;
thing.send(null);
lastpage = GetDo();
break;
case "POST":
document.getElementById(place).innerHTML = "<center>Your request is being processed, please wait...<br /><img src='../gif/load.gif' /></center>";
thing = new DICKBUTT();
thing.open("POST", to, true);
thing.setRequestHeader("Content-type", "applicationx-www-form-urlencoded");
thing.setRequestHeader("Content-length", params.length);
thing.setRequestHeader("Connection", "close");
                glb_location = place;
thing.onreadystatechange = updatePage;
thing.send(params);
break;
}
}

function GetDo()
{
var loc = window.location.href;
var idx = loc.indexOf("?", 0);
var stn = loc.substr(idx);
return stn;
}

function CheckDo()
{
if (GetDo().length > 1 && GetDo() != lastpage)
{
lastpage = GetDo();
GetContent("maincontent.php"+GetDo(), "GET", "here");
return true;
}
return false;
}

function INI()
{
if (CheckDo() == false)
{
GetContent("maincontent.php?do=home", "GET", "here");
}
}
Logged

Xiphirx

wat
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #7 on: August 24, 2008, 01:10:32 am »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
lol, I totally missed the error, I'm quite suprised at myself, its an obvious one at that;

Code: [Select]
thing.onreadystatechange = updatePage(place);
OnReadyStateChange is a function pointer that takes 0 arguments. You need to set it to a function. At the moment all you are doing is setting it to the return value of updatePage, which is going to be null. To fix, do something like this;

Something like this should work (not tested);

Code: [Select]
var lastpage = "notset";
var glb_location = "";
var thing = null;

function DICKBUTT()
{
var request;
try {
request = new XMLHttpRequest();
}
catch (n)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (n2)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (n3)
{
alert("Your Browser does not support DICKBUTT, which is needed to view this website. Please upgrade to the latest version of your favorite browser.");
window.location = "../Index.php";
return false;
}
}
}
return request;
}

function updatePage()
{
        var location = glb_location;
if (thing.readyState == 4)
{
if (thing.status !== 200)
{
document.getElementById(location).innerHTML = "Error, "+thing.status+"";
}
else
{
document.getElementById(location).innerHTML = thing.responseText;
}
}
}

function GetContent(url, method, place)
{
switch (method){
case "GET":
var kl = window.location.href.indexOf("?",0);
lastpage = window.location.href.substr(kl);
document.getElementById(place).innerHTML = "<center>Loading, please wait...<br /><img src='../gif/load.gif' /></center>";
thing = new DICKBUTT();
thing.open("GET", url, true);
                glb_location = place;
thing.onreadystatechange = updatePage;
thing.send(null);
lastpage = GetDo();
break;
case "POST":
document.getElementById(place).innerHTML = "<center>Your request is being processed, please wait...<br /><img src='../gif/load.gif' /></center>";
thing = new DICKBUTT();
thing.open("POST", to, true);
thing.setRequestHeader("Content-type", "applicationx-www-form-urlencoded");
thing.setRequestHeader("Content-length", params.length);
thing.setRequestHeader("Connection", "close");
                glb_location = place;
thing.onreadystatechange = updatePage;
thing.send(params);
break;
}
}

function GetDo()
{
var loc = window.location.href;
var idx = loc.indexOf("?", 0);
var stn = loc.substr(idx);
return stn;
}

function CheckDo()
{
if (GetDo().length > 1 && GetDo() != lastpage)
{
lastpage = GetDo();
GetContent("maincontent.php"+GetDo(), "GET", "here");
return true;
}
return false;
}

function INI()
{
if (CheckDo() == false)
{
GetContent("maincontent.php?do=home", "GET", "here");
}
}

OMG <3

: D
Logged
  • For The Swarm
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #8 on: August 24, 2008, 01:11:14 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3374
I can't really help, but again, if you're using firefox, get the firebug extension. A lifesaver, that one.
Logged
Quote from: Jason
Your community is a bunch of stuck up turds.

Xiphirx

wat
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #9 on: August 24, 2008, 01:19:22 am »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
Since this topic still exists

Code: [Select]
var poststr;
poststr = "name=" + escape(encondeURI( document.getElementById("name").value)) +
"&email=" + escape(encondeURI( document.getElementById("email").value)) +
"&subject=" + escape(encondeURI( document.getElementById("email").value)) +
"&message=" + escape(encondeURI( document.getElementById("email").value)) +
"&id=" + "'.$id.'" +
"&ip=" + "'.$ip.'";
GetContent("processform.php", "POST", "here2", poststr);

That is going to a different page instead of using the function correctly........

it is basically going to index.php?+ poststr
Logged
  • For The Swarm

Xiphirx

wat
Re: URGENT: Javascript / DICKBUTT Woes....
« Reply #10 on: August 24, 2008, 01:35:57 am »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
NVM LOCKED
Logged
  • For The Swarm
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.248 seconds with 60 queries.

anything