473,796 Members | 2,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLhttp request problem

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.asp x",false);
http.send();
if(http.readySt ate == 4)
{
if(http.respons eText!=null && http.responseTe xt!='' )
{
//my process
}
}

server side (aspx page 2)

Response.Clear( );
Response.Conten tType = "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

Oct 12 '05 #1
11 1599
su************* **@gmail.com 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.asp x",false);
http.send();
if(http.readySt ate == 4)
{
if(http.respons eText!=null && http.responseTe xt!='' )
{
//my process
}
}

server side (aspx page 2)

Response.Clear( );
Response.Conten tType = "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 ]

--
Oct 12 '05 #2
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.asp x?nocache=46873 2156795431",fal se);

Oct 12 '05 #3
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.asp x?nocache=46873 2156795431",fal se);


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.javas cript 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?
Oct 13 '05 #4
>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.

Oct 13 '05 #5
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.javas cript 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?
Oct 13 '05 #6
>>>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

Oct 13 '05 #7
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.XMLHttp Request) {
try {http = new XMLHttpRequest( );}
catch(e){http = false;}
} else if (window.ActiveX Object("Microso ft.XMLHTTP")) {
try {http = new window.ActiveXO bject("Microsof t.XMLHTTP");}
catch(e) {
try {http = new window.ActiveXO bject("Msxml2.X MLHTTP");}
catch(e){http = false;}
} else {
http = false;
}
http.open("GET" ,"Gensparql.asp x",true);
http.onreadysta techange = function() {
if (http.readyStat e == 4)
if (http.status == 200) {
//my process
}
}
http.send(null) ;

Oct 13 '05 #8
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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 13 '05 #9
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.
Oct 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3261
by: Irene | last post by:
Hi, I have an asp page that allows a user to search for info in a DB and add info to a DB. The search uses "ADODB.Connection" objects in the page, but the add will use a call to an isapi dll via the "Microsoft.XMLHTTP" object. The results of the isapi dll will be displayed to the user without refreshing the asp page. I have a code snippet below for the isapi call. WHat is happening is that the xmlhttp.responseText from the snippet...
3
1992
by: kajol | last post by:
Hi everyone I am trying to get the content of any webpage (URL) using XMLHTTP, and it is working fine for me, but suddenly I have got a URL "http://www.bizrate.com/" which is causing a system error and the error is System.Runtime.InteropServices.COMException(0xC00CE56E): System error:- 1072896658
3
3093
by: Mark | last post by:
Hi all i was just wondering if you help. I have to send a cgi request to a company using xmlhttp request. They reply back with a line of info but when you view the internet explorer source code you see the XML format. I was just wonder if anyone could help me save the xml format to a xml file. I woul like to show you my code but there is to much confidential information about the company.
5
449
by: jim.frantzen | last post by:
You have an active XMLHTTP request on the main page (localhost/App1/index.aspx) The XMLHTTP request takes about 60 seconds to receive a response back from localhost/App1/getxml.aspx. You have an IFRAME on this main page. When you set the iframe's src to google.com, it works fine. When you set the iframe's src to localhost/App1/test.htm, it works fine. When you set the iframe's src to
9
2384
by: balakrishnan.dinesh | last post by:
hi friends, Exactly what i want to know is, In my product we are using xmlhttp request to retrive some data from the server, And Im using IE browser, its working fine in IE. Now i want to work with netscape,I dont know how to pass the xmlhttp request in Netscape. i got some code like below for netscape for xmlhttp var oXML=new XMLHttpRequest();
4
11438
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the XMLHTTP object. However, when the page requested through the XML object makes a <%Response.Redirect()%> call, a new session is created each time. Is this a flaw in the XMLHTTP Object? How can I force the session to remain the same after a...
0
2752
by: SushiSean | last post by:
When executing the xmlhttp.send function to request shipper for available shipments (I send xml as string and receive result xml): XMLHTTP xmlhttp = new XMLHTTP(); xmlhttp.open("POST", "https://gateway.fedex.com:443/GatewayDC", false, "", ""); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlhttp.send(strXML);
1
1586
by: tsangkinyip | last post by:
Hi there, I have a diary page where I would like to fade in the text content and an image when a user tries to click on a date in the calendar. Things work fine offline, but when I upload the files to the server I've found that the server is much slower than I've thought and the xmlhttp request has been executed before getting the image and body objects, which leads to a javascript error. May I ask what I can do to solve the problem?...
4
8285
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my problems and this one is really getting to me... I have a page that allows you to Browse Authors. There are three drop down boxes that auto-populate via AJAX. I have a file which it calls and returns the dynamically built XML file in the boxes...
3
19060
by: JMcCrillis | last post by:
I've implemented a FileUpload servlet using AJAX and JS. It appears to be working well but for one issue. I used XMLHTTP so I could intercept the response in Javascript and write it out to a field on my webpage. I get back that my readyState is 4 and my status is 200 and status text is "OK", but my responseText is always empty. Both on FireFox and IE7, so it must be something I'm doing (wrong). I've also set up an IFRAME to redirect the...
0
10236
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.