Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > XMLhttp request problem

Reply
Thread Tools

XMLhttp request problem

 
 
sudhaoncyberworld@gmail.com
Guest
Posts: n/a
 
      10-12-2005
Hi all

i am using asp.net v2.0

In one of my page i am calling another page using xml http , this is
working fine but first time only ,

I am sending the request on click of button , when i click the button
second time, it's returning the previous response and it's not even
calling that page again, where could be the problem.

client side (aspx page 1- javascript)

var http=new ActiveXObject("Msxml2.XMLHTTP");
http.open("GET","Gensparql.aspx",false);
http.send();
if(http.readyState == 4)
{
if(http.responseText!=null && http.responseText!='' )
{
//my process
}
}

server side (aspx page 2)

Response.Clear();
Response.ContentType = "text/xml";
Response.Write(retVal);
Response.End();

//second time returning same previous output and not calling the aspx
page 2
Hope u understand my problem,i am in urgent, Thanks in advance

 
Reply With Quote
 
 
 
 
knocte
Guest
Posts: n/a
 
      10-12-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) escribió:
> Hi all
>
> i am using asp.net v2.0
>
> In one of my page i am calling another page using xml http , this is
> working fine but first time only ,
>
> I am sending the request on click of button , when i click the button
> second time, it's returning the previous response and it's not even
> calling that page again, where could be the problem.
>
> client side (aspx page 1- javascript)
>
> var http=new ActiveXObject("Msxml2.XMLHTTP");
> http.open("GET","Gensparql.aspx",false);
> http.send();
> if(http.readyState == 4)
> {
> if(http.responseText!=null && http.responseText!='' )
> {
> //my process
> }
> }
>
> server side (aspx page 2)
>
> Response.Clear();
> Response.ContentType = "text/xml";
> Response.Write(retVal);
> Response.End();
>
> //second time returning same previous output and not calling the aspx
> page 2
> Hope u understand my problem,i am in urgent, Thanks in advance
>



Perhaps you must send HTTP headers informing about how cacheable is the
content. You could write it so as to expire immediately. BTW, don't use
only ActiveX, or else other (standards compliant) browsers won't work
with your page.

Andrew [ knocte ]

--
 
Reply With Quote
 
 
 
 
Jambalaya
Guest
Posts: n/a
 
      10-12-2005
Append a random number after the url that's being called. The browser
will not use the cache. Just make sure to use a different random number
for each call.

http.open("GET","Gensparql.aspx?nocache=4687321567 95431",false);

 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      10-13-2005
Jambalaya said the following on 10/12/2005 10:25 AM:
> Append a random number after the url that's being called.


And what is that for?

> The browser will not use the cache.


It will if I tell it to.

> Just make sure to use a different random number for each call.


Each call of what?

>
> http.open("GET","Gensparql.aspx?nocache=4687321567 95431",false);
>


Oh wait, I see now. If you had bothered to quote what you were replying
to it would be easier to see that your approach has a simple flaw in it.
Instead of just trying to guess at a random number, you append the
current time in milliseconds.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
Reply With Quote
 
Jambalaya
Guest
Posts: n/a
 
      10-13-2005
>Oh wait, I see now. If you had bothered to quote what you were replying
>to it would be easier to see that your approach has a simple flaw in it.
>Instead of just trying to guess at a random number, you append the
>current time in milliseconds.


There was no flaw. Just a different method to accomplish the goal.

--
Jambalaya
Question: What's the #2 most annoying thing on Usenet?
Answer: Netiquette Nazis.

 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      10-13-2005
Jambalaya said the following on 10/13/2005 12:22 AM:

>>Oh wait, I see now. If you had bothered to quote what you were replying
>>to it would be easier to see that your approach has a simple flaw in it.
>>Instead of just trying to guess at a random number, you append the
>>current time in milliseconds.

>
>
> There was no flaw. Just a different method to accomplish the goal.


And what method is that? Since you did not elaborate and your code was
hard-coded and showed no signs of being generated, it indicated that one
should hard-code that random number. That is a flaw in the approach -
not a different method to accomplish the same goal.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
Reply With Quote
 
Jambalaya
Guest
Posts: n/a
 
      10-13-2005
>>>Oh wait, I see now. If you had bothered to quote what you were replying
>>>to it would be easier to see that your approach has a simple flaw in it.
>>>Instead of just trying to guess at a random number, you append the
>>>current time in milliseconds.


>> There was no flaw. Just a different method to accomplish the goal.


>And what method is that?


You really do seem smarter than this, Randy. I was showing the end
result of the concatenation so that the original poster would
understand the concept. I wasn't writing the code for him. I assume
since he is using xmlhttp that he has sufficient javascript knowledge
to be able to generate a random number and append it to a string.

>Since you did not elaborate and your code was
>hard-coded and showed no signs of being generated, it indicated that one
>should hard-code that random number.


No, if you will reread my first post, it indicates the opposite. I
quote myself, "Just make sure to use a different random number for each
call."

>That is a flaw in the approach -
>not a different method to accomplish the same goal.


I guess I'll admit there was a flaw. And that is that I didn't write
all the javascript for the original poster. I guess I'm more of a
teach-a-man-to-fish sort of guy versus a give-a-man-a-fish guy.

J

 
Reply With Quote
 
Andrew Stephanoff
Guest
Posts: n/a
 
      10-13-2005
1.You must generate XML-content on php or ASP and set th header with
following info: "Content-type: application/xml; Cache-control:
no-cache;". If you use "clear" XML, the content will be cached.
2. Code in javascript will be follow:

var http;
if (window.XMLHttpRequest) {
try {http = new XMLHttpRequest();}
catch(e){http = false;}
} else if (window.ActiveXObject("Microsoft.XMLHTTP")) {
try {http = new window.ActiveXObject("Microsoft.XMLHTTP");}
catch(e) {
try {http = new window.ActiveXObject("Msxml2.XMLHTTP");}
catch(e){http = false;}
} else {
http = false;
}
http.open("GET","Gensparql.aspx",true);
http.onreadystatechange = function() {
if (http.readyState == 4)
if (http.status == 200) {
//my process
}
}
http.send(null);

 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      10-13-2005
Jambalaya said the following on 10/13/2005 4:30 AM:

>>>>Oh wait, I see now. If you had bothered to quote what you were replying
>>>>to it would be easier to see that your approach has a simple flaw in it.
>>>>Instead of just trying to guess at a random number, you append the
>>>>current time in milliseconds.

>
>
>>>There was no flaw. Just a different method to accomplish the goal.

>
>
>>And what method is that?

>
>
> You really do seem smarter than this, Randy. I was showing the end
> result of the concatenation so that the original poster would
> understand the concept. I wasn't writing the code for him. I assume
> since he is using xmlhttp that he has sufficient javascript knowledge
> to be able to generate a random number and append it to a string.


Now it makes sense

>
>>Since you did not elaborate and your code was
>>hard-coded and showed no signs of being generated, it indicated that one
>>should hard-code that random number.

>
>
> No, if you will reread my first post, it indicates the opposite. I
> quote myself, "Just make sure to use a different random number for each
> call."


Fair enough.

>
>>That is a flaw in the approach -
>>not a different method to accomplish the same goal.

>
>
> I guess I'll admit there was a flaw. And that is that I didn't write
> all the javascript for the original poster. I guess I'm more of a
> teach-a-man-to-fish sort of guy versus a give-a-man-a-fish guy.


That's probably why I didn't write the script either, huh? <g>

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      10-13-2005
Jambalaya wrote:
<snip>
>>... , it indicated that
>>one should hard-code that random number.

>
> No, if you will reread my first post, it indicates the
> opposite. I quote myself, "Just make sure to use a
> different random number for each call."


It is considerably easier to say "just make sure to use a different
random number for each call" (assuming "call" is acceptable terminology
here (which it probably isn't)) than to actually do it. Remember that
you would have to be keeping track of which random numbers had been
used, even between sessions, as it would not be too good if the browser
decided to deliver content that it had downloaded in a previous session
from its cache in response to a request in a later one.

That is why using the millisecond time in this context has been
proposed, as each time will be unique (at least so long as no two times
are requested within about 60 milliseconds, at most) and it is in the
nature of time that is does not repeat itself. That is; what is wanted
is a unique number rather than a random one, and each item in a sequence
of increasing integer values is unique within that sequnce.

>>That is a flaw in the approach -
>>not a different method to accomplish the same goal.

>
> I guess I'll admit there was a flaw.


Yes it is. At lest in part because the proposal that the OP should "make
sure" that no two random numbers be the same is considerably more
troublesome than an available alternative.

> And that is that I didn't write
> all the javascript for the original poster.
> I guess I'm more of a teach-a-man-to-fish sort
> of guy versus a give-a-man-a-fish guy.


"Fishing" in an HTTP context would be better mastered with an
understanding of HTTP, and specifically the way in which various HTTP
headers can be configured to discourage client-side caching of various
resources (and possibly the different ways in which POST and GET
requests are handled with regard to caching). With the correct header
configuration it is possible that the URL hack would be unnecessary,
else you would see such "random numbers" on the end of every URL on
every dynamic site.

Richard.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Xmlhttp request abcdefghij Software 0 06-04-2010 06:09 AM
Msxml*.XMLHTTP vs. Microsoft.XMLHTTP yawnmoth Javascript 11 11-09-2006 08:44 PM
Integrated Security problem on XMLHTTP Request - Finaly IE Crash damianarielfernandez@gmail.com ASP .Net 0 10-19-2006 11:18 AM
XMLhttp request problem SudhaGSD ASP .Net Web Controls 1 10-14-2005 10:45 AM
Problem with XMLHTTP request. Please help! (long) Robert Cholewa Javascript 1 12-19-2004 07:09 PM



Advertisments