469,946 Members | 1,805 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Handler Does not work in Firefox

2
I created this generic AJAX Handler to work with Firefox and IE. However, it seems that somewhere in updating Firefox to 2.0.0.9 that the handler assigned to onreadystatechange is no longer getting called. This still works for IE.

Can someone help me add to this so that I can get it working with Firefox again?

Expand|Select|Wrap|Line Numbers
  1. var ASYNCH       = true;
  2. var REQUEST_TYPE = 'POST';
  3. var AJAX_URL     = '/ajax.cgi';
  4.  
  5. function httpRequest() {
  6.     // Mozilla-based browsers
  7.     if (window.XMLHttpRequest) {
  8.         ajaxRequest = new XMLHttpRequest();
  9.     }
  10.     // IE-based browsers
  11.     else if (window.ActiveXObject) {
  12.         ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  13.  
  14.         if(! this.ajaxRequest) {
  15.             ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  16.         }
  17.     }
  18.     // The request could still be null if neither ActiveXObject
  19.     // initialization succeeded
  20.     if (! ajaxRequest) {
  21.         alert("Your browser does not permit the use of all of this " +
  22.             "application's features");
  23.         return false;
  24.     }
  25.     ajaxRequest.onreadystatechange = this.handler; // DOES NOT WORK IN Firefox 2.0.0.9
  26.     ajaxRequest.open( REQUEST_TYPE, AJAX_URL, ASYNCH);
  27.     ajaxRequest.setRequestHeader("Content-Type",
  28.         "application/x-www-form-urlencoded; charset=UTF=-8"
  29.     );
  30.     ajaxRequest.send( this.queryString );
  31.     return true;
  32. }
Nov 7 '07 #1
5 1892
acoder
16,027 Expert Mod 8TB
Could you post the code for the handler?
Nov 7 '07 #2
Herkum
2
Could you post the code for the handler?
I think I did not make myself clear, the handler never gets called in Firefox. It works perfectly in IE and it HAD worked in Firefox before I upgraded it. So it is something specific to recent versions of Firefox.

I was hoping someone could help add some code to handle the problem that is occurring specifically to Firefox.
Nov 7 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

have a look at the FF javascript-console ... are there any errors?

kind regards
Nov 7 '07 #4
Friends, try remove the code line follow:

ajaxRequest.onreadystatechange = this.handler;

I tried it, and this works perfectly at the FF, Chrome and IE 6, 7 and 8.

Kind regards.
Oct 14 '10 #5
gits
5,390 Expert Mod 4TB
then there is no response-handler?? how ist the response handled now?

this.handler in the original post had to be a handler-function which would have been to be declared for the custom httpRequest function/object ... and it is missing in the posted code ... at least there should be something like:

Expand|Select|Wrap|Line Numbers
  1. ajaxRequest.onreadystatechange = function(response) {
  2.     // do something with response
  3. };
Oct 15 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Clarence Gardner | last post: by
1 post views Thread by cjl | last post: by
3 posts views Thread by jeff29_b | last post: by
3 posts views Thread by =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.