AJAX and Application variable (ASP)

R

Ruso

I am using ASP to make an application. What I want right now - is to
make the self updating list of the users online - based on thier
cookies. In my opinion all seems to be writen well with it's logic, but
computer thinks otherwise. I use application("loged") to store the
cookies of all users.

Here is a code:

main.asp


<%
if len(request.Cookies("name"))=0 then
Randomize
qqq = Rnd
Response.Cookies("name")=qqq
end if
%>


<script type="text/javascript" language="JavaScript1.2"
src="prototype-1.4.0.js"></script>
<script>
var x=0;
var http = createRequestObject();
function createRequestObject() {
var objAjax;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
objAjax = new ActiveXObject("Microsoft.XMLHTTP");
}else{
objAjax = new XMLHttpRequest();
}
return objAjax;
}

function getNewContent(){
http.open('get','login.asp?cookie=<% =request.Cookies("name") %>');
http.onreadystatechange = updateNewContent;
http.send(null);
return false;
}

function updateNewContent(){
x++;
if(http.readyState == 4){
document.getElementById('mySentence').innerHTML = http.responseText +x
;
}
}

new PeriodicalExecuter(getNewContent, 4);
</script>
..
..
..


login.asp

<%
if instr(Application("loged"), Request.QueryString("cookie"))=0 then
Application("loged")= Application("loged") & "|" &
Request.QueryString("cookie")
end if
response.write Application("loged")
%>


When the page is refreshed with AJAX function, no new names are shown
on the page. But when I click f5 (refresh) all conection do appear.

Any idea what's wrong??
 
L

Laurent Bugnion

Hi,
I am using ASP to make an application. What I want right now - is to
make the self updating list of the users online - based on thier
cookies. In my opinion all seems to be writen well with it's logic, but
computer thinks otherwise. I use application("loged") to store the
cookies of all users.

Any reason why you use ASP? I would move to ASP.NET if I were you, the
model is much much clearer and easier to grasp (though more elaborate)
than in ASP. Also, it's very very easy to debug AJAX in ASP.NET, by
setting breakpoints on both the server and the client. But that's off topic.

About your problem, if I were you, I would check exactly what is sent to
the ASP page, and what is returned. I use Fiddler to do that, it allows
to see the complete request and response. Other tools exist, for example
Firebug for Firefox.

Once you did that, use a client-side debugger to inspect what you
receive, and how your program reacts. On Firefox, you can use Venkman.
On IE, I use Visual Studio 2005, which works excellently.

HTH,
Laurent
 
R

Ruso

Thanks for reply.

Laurent said:
Hi,


Any reason why you use ASP? I would move to ASP.NET if I were you, the
model is much much clearer and easier to grasp (though more elaborate)
than in ASP. Also, it's very very easy to debug AJAX in ASP.NET, by
setting breakpoints on both the server and the client. But that's off topic.

I am using ASP because I dont know asp.net at all :(
About your problem, if I were you, I would check exactly what is sent to
the ASP page, and what is returned. I use Fiddler to do that, it allows
to see the complete request and response. Other tools exist, for example
Firebug for Firefox.

I will try what you do sugest, and see what is send to each page, but I
do know that the cookie value is passed correctlly. And it's the only
value I do pass to the login.asp page at the moment.
Once you did that, use a client-side debugger to inspect what you
receive, and how your program reacts. On Firefox, you can use Venkman.
On IE, I use Visual Studio 2005, which works excellently.

Can you explain this part a bit more??
 
R

Ruso

Ruso said:
Thanks for reply.



I am using ASP because I dont know asp.net at all :(


I will try what you do sugest, and see what is send to each page, but I
do know that the cookie value is passed correctlly. And it's the only
value I do pass to the login.asp page at the moment.


Can you explain this part a bit more??



I used Fiddler to check for the traffic, and I discovered that the page
login.asp is only called once, and I want to call it evry copule of
seconds. So whats wrong with the ajax script then?? Any idea any1??
 
L

Laurent Bugnion

Hi,

I mean that Venkman and Visual Studio 2005 (or 2003 for that matter)
allow you to debug client-side JavaScript, which makes it a big deal
easier to see what's wrong with your code. I'd recommend Venkman,
because it's free and easy to install.
I used Fiddler to check for the traffic, and I discovered that the page
login.asp is only called once, and I want to call it evry copule of
seconds. So whats wrong with the ajax script then?? Any idea any1??

You use an external library named prototype.js. Unfortunately, I have no
idea how it works. I would contact the library's maker and ask.

HTH,
Laurent
 
R

Ruso

Laurent said:
Hi,


I mean that Venkman and Visual Studio 2005 (or 2003 for that matter)
allow you to debug client-side JavaScript, which makes it a big deal
easier to see what's wrong with your code. I'd recommend Venkman,
because it's free and easy to install.


You use an external library named prototype.js. Unfortunately, I have no
idea how it works. I would contact the library's maker and ask.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Problem solved. I dont know what was the error, but when I rebuild it
from scratch it worked. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top