/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Ajax Event Handler Problem

In the same document, I sometimes want to perform an asynchronous Ajax call and other times I want to perform a synchronous call. For the asynchronous call, of course, I associate a handler with the [b]onreadystatechange[/b] event. For the synchronous call, I don’t want a handler associated with that event — but I can’t seem to find a method for clearing (resetting) the association once it has been made. If I try to set it to [b]null[/b], I get a type mismatch error. I also tried using the [B]delete[/B] operator, but (though no error) that didn’t remove the association. Solution?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@VladdyMay 11.2006 — make another instance of xmlhttprequest
Copy linkTweet thisAlerts:
@phpnoviceauthorMay 11.2006 — You mean make a new one each time I need it? ...or, make one for synchronous and one for asynchronous operations? In either case, it seems non-sensical to have to go to that extent. Instead of workaround, isn't there a solution?
Copy linkTweet thisAlerts:
@phpnoviceauthorMay 12.2006 — OK, came up with a better workaround for my solution:
if (opt) xmlhttp.onreadystatechange = func; // assign function for response
else xmlhttp.onreadystatechange = function(){return true};
×

Success!

Help @phpnovice spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...