javascript - SCRIPT65535: Invalid calling object in IE9 -


i new javascript. facing issue in else written code. have created security.js file , trying overwrite xmlhttprequest (am not sure). attaching code here.

(function () {     function getxhrobj(baseobj){         var impl = function(){                       this.onreadystatechange = null;             return this;         };         //impl.prototype.onreadystatechange = null;             // set prototype of new constructor         impl.prototype = baseobj;           //impl.prototype.constructor = impl; // not work in ie              // object returned         var retobj = new impl();          function ishttpreq(url){             if(url){                 var colindx = url.indexof('://');                 if((colindx < 0)                      || (url.substr(0, colindx).tolowercase().indexof('http') == 0))                     return true;             }             return false;         }              // customize open add token in url             // post request should since post may not have key=value&... data format         retobj.open = function(method, url, async, user, pwd){              if(ishttpreq(url)){                          var prefix = (url.indexof('?') < 0)? '?' : '&';                 url += (prefix + window.csrftoken);             }             //alert('making ajax - ' + url);             impl.prototype.open(method, url, async, user, pwd);         };              // customize send         retobj.send = function(body){                  /* register handler before "send" allow reuse of same object */             impl.prototype.onreadystatechange = function(){                 //alert('impl.prototype.readystate- '+ impl.prototype.readystate);                      // copy properties return object                 if(impl.prototype.readystate)                     retobj.readystate = impl.prototype.readystate;                   if(impl.prototype.readystate == 4){                     if(impl.prototype.status)                         retobj.status = impl.prototype.status;                      if(impl.prototype.statustext)                         retobj.statustext = impl.prototype.statustext;                      if(impl.prototype.responsetext)                         retobj.responsetext = impl.prototype.responsetext;                      if(impl.prototype.responsexml)                         retobj.responsexml = impl.prototype.responsexml;                     //alert('xml done');                 }                     // publish event return object handler                 if(retobj.onreadystatechange){                     //alert('invoking handler - \n' + retobj.onreadystatechange);                     retobj.onreadystatechange();                 }else{                     //alert('no handler');                 }             };               impl.prototype.send(body);                   };              // delegate other methods             /* redefinition necessary because ie not allow inheritance                 native objects */         retobj.abort = function() {             impl.prototype.abort();         };          retobj.setrequestheader = function(hdr, val){             impl.prototype.setrequestheader(hdr, val);         };          retobj.getresponseheader = function(hdr){             return impl.prototype.getresponseheader(hdr);         };          retobj.getallresponseheaders = function(){             return impl.prototype.getallresponseheaders();         };          return retobj;     }          // redefine xmlttprequest use custom definition     if(window.xmlhttprequest){         var base_xmlhttprequest = window.xmlhttprequest;         window.xmlhttprequest = function(){             //alert('in new xhr');             return getxhrobj(new base_xmlhttprequest());         };     }          // redefine activexobject use custom definition     if(window.activexobject) {         var base_activexobject = window.activexobject;         window.activexobject = function(objtype){             //alert('in new activexobj - ' + objtype);                   if((objtype.tolowercase() != "microsoft.xmlhttp")                  &&(objtype.tolowercase().indexof("msxml2.xmlhttp") < 0)){                     // return standard impl non-ajax objects                 return new base_activexobject(objtype);             }else{`enter code here`                 //alert('returning new impl ' +  objtype);                 return getxhrobj(new base_activexobject(objtype));             }         };     } })(); 

this code working fine in ie7 & 8, giving error in other browsers. ie9 error -

script65535: invalid calling object security.js, line 71 character 4

error pointing this.onreadystatechange = null;

var impl = function(){                           this.onreadystatechange = null;                 return this;             }; 

appreciate immediate help. thanks!


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -