| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Mark,
Niels
On Nov 12, 2006, at 11:09 AM, Mark Baldwin wrote:
Not true! It's totally reusable. The trick is to call open before assigning the readystate handler or doing any other assignments. If you need more info a quick google on 'XMLHttpRequest reuse' will get you what you need.
You will need to look at the readystate and if a request is initiated while one is still outstanding call abort() on the object. Other than that, it is possible to reuse the object as much as you want.
Mark
On Nov 12, 2006, at 7:53 AM, Niels Meersschaert wrote:
XMLHttpRequest isn't really reusable. In this case, what you'd want to do is something like this:
var req;
function buildRequest(url,xml) { req = new XMLHttpRequest() req.onreadystatechange = process; req.open("POST", url, true); req.send(xml); }
This way, a new XMLHttpRequest object is created, but the reference (req) is maintained outside the function so that your handler can support it. Each time you want to call the request, simply call the buildRequest method with the url & the xml you need.
Niels
On Nov 12, 2006, at 8:55 AM, David Allen wrote:
I have a program that requires multiple XMLHTTPRequests. I use the following code in a loop:
var req = new XMLHttpRequest(); req.onreadystatechange = process; req.open("POST", "http://url.com:port/page.cgi", true); req.send("Lots and lots of XML")
When I run it the first time, everything goes smoothly, but when I run
it the second time, req.open fails to work - i.e. req.readyState stays
0 afterwards.
Any ideas?
Thanks,
David._______________________________________________ Do not post admin requests to the list. They will be ignored. Web-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/web-dev/email@hidden
This email sent to email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Do not post admin requests to the list. They will be ignored. Web-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/web-dev/email@hidden This email sent to email@hidden
| References: | |
| >XMLHTTPRequest Issues (From: "David Allen" <email@hidden>) | |
| >Re: XMLHTTPRequest Issues (From: Niels Meersschaert <email@hidden>) | |
| >Re: XMLHTTPRequest Issues (From: Mark Baldwin <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.