Ajax on firefox conversion problems

I am in the process of converting our web application to support firefox where it was written around IE. I have a Lock control object that is designed lock a schedule from being edited and maintain the lock. Works great on IE, fire fox throws this error.

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.setRequestHeader]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: http://localhost:8080/themes/common/js/scheduling/LockControl.js :: anonymous :: line 21"  data: no]



I have had no luck finding a solution for this anywhere can someone helps...


here is the source...
            function createRequestObject() {
                var ro;
                var browser = navigator.appName;
                if(browser == "Microsoft Internet Explorer"){
                    ro = new ActiveXObject("Microsoft.XMLHTTP");
                }else{
                    ro = new XMLHttpRequest();
                }
                return ro;
            }


function LockControl(self, date, employee)
{
      this.self = self;
      this.date = date;
      this.employee = employee;
      this.lastEditBy = "";
      this.params = "zDate="+this.date+"&emp="+this.employee;
      this.checkObj = createRequestObject();
      this.editObj = createRequestObject();
      this.releaseObj = createRequestObject();
            
            
            
            
      
      this.sndReq = function(obj, URL, Params, handleResponse)
      {
            obj.open('post', URL, true);
            obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            obj.onreadystatechange = handleResponse;
            obj.send(Params);

      }
      
      
      
      
      this.checkEdit = function()
      {
            //alert("check");
            this.sndReq(this.checkObj, 'ajaxcalls/checkDayLock.jsp', this.params, this.handleCheckEdit);
      }
      
      this.requestEdit = function()
      {
            this.sndReq(this.editObj, 'ajaxcalls/setDayLock.jsp', this.params, this.handleRequestEdit);
      }
      
      this.requestRelease = function()
      {
            this.sndReq(this.releaseObj, 'ajaxcalls/releaseDayLock.jsp', this.params,  this.handleRequestRelease);
      }
      
      
      
      
      
      
      this.handleCheckEdit = function()
      {
      
            if(gLockControl.checkObj.readyState == 4)
            {
                  ///omitted
                        
            }
      }
      
      this.handleRequestEdit = function()
      {
      
                  if(gLockControl.editObj.readyState == 4)
                  {
                  ///omitted
                              
            }
      }


      this.handleRequestRelease = function()
      {
      
                  if(gLockControl.releaseObj.readyState == 4)
                  {
                  ///omitted
                              
            }
      }



}

any ideas on what I need to change to get this working on firefox?
LVL 11
IsisagateAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
Show an example of the LockControl(self, date, employee) call.

IsisagateAuthor Commented:
var gLockControl = new LockControl("gLockControl",gDateCurrentDay,gCurrentEmployeeName);


g infront of the variable is denoting a global variable on the page. for instance the gDateCurrentDay is set by the jsp on the page.. so is the gCurrentEmployeeName. The LockControl Object is in a js include file so this was a way of keeping the js file from being jsp.

all the parameters being passed it are strings.

IsisagateAuthor Commented:
when I call the object through out the page I do...

gLockControl.checkEdit();
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

ZvonkoSystems architectCommented:
I wonder why you choosed "self" as parameter name. That is an alias for window root node. Anyway, that is not the reason for FireFox to break. It seams more that is the difference how storage is managed. I wonder that above code works in IE.
Let me make some tests...

IsisagateAuthor Commented:
The choice of self was just to self document that the parameter was to be the name of the object on the code level for use with an eval statement, however I abandoned the eval and opted to just outright call for the gLockControl.
ZvonkoSystems architectCommented:
OK, I did not got any errors. It works for me in IE6.0 and FF1.5.0.6

Here are my calls:

var gDateCurrentDay = "11/22/2006";
var gCurrentEmployeeName = "EE";

var gLockControl = new LockControl("gLockControl",gDateCurrentDay,gCurrentEmployeeName);

gLockControl.checkEdit();

</script>


The error you got does say that you tried to set request headers before open() call. But that is not true in your code. So it is something strange, timing errors or so. Do you call that function several times?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZvonkoSystems architectCommented:
And this is a demo of self:


var someVar = "var value";
alert(self["someVar"]);



IsisagateAuthor Commented:
I do have it called on an Interval
ZvonkoSystems architectCommented:
Bingo!  Increase the interval timer.
IsisagateAuthor Commented:
I have the interval set to 7 seconds and it seems to still do it
ZvonkoSystems architectCommented:
That's strange...
The problem is that after one request is fired you should NOT change the request object untill the response arives.
IsisagateAuthor Commented:
Well I tested that theory with a primitive global lock arount the contents of the snd request mechanism, checking the boolean to see if it's false then running the send function and in the handler it will set it to false when readyState =4 after it done processing. I'm still getting the same error. Any other suggestions?
ZvonkoSystems architectCommented:
Can I get access to your page to see it live?
IsisagateAuthor Commented:
I sent you login and password info since this is a private site at the moment.
ZvonkoSystems architectCommented:
I did not get it yet. Anyway, I am on the way home and go out then for dancing :)
IsisagateAuthor Commented:
There maybe some moments of downtime during the day as we will be doing some profiling on the system's quoting section.
ZvonkoSystems architectCommented:
Did you remove the underscores from my email address?
IsisagateAuthor Commented:
that's cool check it out when you get a chance, I'm sure the bug will still be there monday as we are gonna work on profiling what is working for the rest of the day.
IsisagateAuthor Commented:
yes I removed the underscores... it might just be a little slow
IsisagateAuthor Commented:
I fixed it. It's a simple bug really. Because I only have 3 XMLHttpRequest objects setup for the 3 processes, one of the objects is having a call to it made before the other one finishes up. so this is causing the conflict. I fix this as a side effect of putting in code on the page to have a request manager that adds more request objects when all the others are in use for use with other functionality on this page.
ZvonkoSystems architectCommented:
Thank you for feedback.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.