Corrupted Get request

Hi

Got a bit of an urgent issue here.

My site isn't loading at all in IE7.  I'm getting an Error 400, bad request.  The microsoft help page says it's a corrupted get request.  Presumably because of the method in the function below which is calling prototype.js (http://www.prototypejs.org/).  It works fine in IE6 and Firefox though.  Confused.

I tried method post instead and that's not allowed on the server.  Is it a simple matter for the server administrator to sort this out?  Or will I need to change the code?

Thanks

function  populateBox (serverPage, obj){
      var objID = "iboxtext";
      new Ajax.Updater(objID, serverPage, {method:'get', onComplete:function(){
                        //change tab color
                        if(obj != null){
                              var links = $('infoboxtabs').getElementsByTagName('A');
                              for (var i=0; i<links.length; i++) {
                                    links[i].className = 'plain';  
                              }
                              obj.className = 'highlighted';
                        }
                       
                  }
            }
      );
     
      return false;
}
//load initial page.
Event.observe(window, 'load', function(){ populateBox('page.html', null); });
Lady_MAsked:
Who is Participating?
 
ZvonkoConnect With a Mentor Systems architectCommented:
Simplify this first:
//load initial page.
Event.observe(window, 'load', function(){ populateBox('page.html', null); });

To this:
window.onload= function(){populateBox('page.html', null)};



0
 
ZvonkoConnect With a Mentor Systems architectCommented:
And you have a semantic problem in your function populateBox()
You cannot use the parameter obj in the anonymous function() assigned to the onComplete property. The parameter obj is visible ONLY inside the function populateBox(). At end of populateBox() does obj discard and the anonymous function() cannot see it.

What you can do is this:

var theObj=null;
function  populateBox (serverPage, obj){
      theObj = obj;
      var objID = "iboxtext";
      new Ajax.Updater(objID, serverPage, {method:'get', onComplete:function(){
                        //change tab color
                        if(theObj != null){
                              var links = $('infoboxtabs').getElementsByTagName('A');
                              for (var i=0; i<links.length; i++) {
                                    links[i].className = 'plain';  
                              }
                              theObj.className = 'highlighted';
                        }
                  }
            }
      );
      return false;
}

// sidenote: only the last call wins and last theObj is highlighted, but that should be ok.



0
 
Lady_MAuthor Commented:
Thankyou, it works.  That's a big relief!  Thought it was going to be a day of agonising.
I'm not very sure what you meant by your explanation, if you get time could you try explaining it again in words of one syllable please?
Thanks
PS, I can't use the window.onload because IE refuses to do it.
0
 
ZvonkoConnect With a Mentor Systems architectCommented:
There can be only one onload statement. The last assignment wins. So if you have in the body tag also an onload="" assignment, then it will win, or when you have anywhere on the page a second onload then does that onload overwrite all previous onload assignments.

The last side note does say this in plain English: the event onComplete is fired outside of the scope of the function populateBox(), so all local visible variables of the function populateBox() are not visible outside the function. All variables in a function defined with a var prefix are of scope local, also all passed variables in the function parameter braces are local variables to the function. To be able to get the variable in another function you need a global variable. The global variable is defined by defining a var outside of any function body, then is the var global and can be used from anywhere on the page.
Is that description readable to you?

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.