469,356 Members | 2,644 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

AJAX and Application variable (ASP)

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??

Nov 14 '06 #1
5 3196
Hi,

Ruso wrote:
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
>
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??

--
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
Nov 14 '06 #2
Thanks for reply.

Laurent Bugnion wrote:
Hi,

Ruso wrote:
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.
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??

HTH,
Laurent

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??


--
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
Nov 14 '06 #3

Ruso wrote:
Thanks for reply.

Laurent Bugnion wrote:
Hi,

Ruso wrote:
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.

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??

HTH,
Laurent
>
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??
>

--
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


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??

Nov 14 '06 #4
Hi,

Ruso wrote:
Ruso wrote:
>Thanks for reply.

Laurent Bugnion wrote:
>>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??
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
--
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
Nov 14 '06 #5

Laurent Bugnion wrote:
Hi,

Ruso wrote:
Ruso wrote:
Thanks for reply.

Laurent Bugnion wrote:
>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??

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
--
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. :)

Nov 15 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by =?Utf-8?B?bmFuZGFu?= | last post: by
9 posts views Thread by dougloj | last post: by
1 post views Thread by geevaa | last post: by
3 posts views Thread by bbawa1 | last post: by
6 posts views Thread by =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post: by
16 posts views Thread by deostroll | last post: by
11 posts views Thread by Jonathan Wood | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.