AJAX request cannot be created - (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open] error

View: New views
1 Messages — Rating Filter:   Alert me  

AJAX request cannot be created - (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open] error

by Amit Jagtap :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am trying to develop a generic AJAX object so that I can reuse it across my application.
Following is the code for it -
function async(url,cbFun){
        this.req;
        this.callBackcbFun;
        this.url=url;

        this.initRequest=function (){
                if (window.XMLHttpRequest) {
                        this.req = new XMLHttpRequest();
                }
                else if (window.ActiveXObject) {
                        this.req = new ActiveXObject("Microsoft.XMLHTTP");
                }
        }

        this.doAjax=function() {
                this.initRequest();
                this.callBack = cbFun;

                if (this.req != null){
                        this.req.onreadystatechange = function(){
                                if (this.req.readyState == 4){
                                        this.callBack(this.req.responseText,this.req.responseXML,this.req.readyState,this.req);
                                }
                                else{
                                        // Invoke Stalker...
                                }
                        };

                        this.req.open("GET", url, true);
                        this.req.send(null);
                }
                else{
                        alert ("No Request Object created!!!");
                }
        }
}

But, I recieve the following error -


Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame :: http://localhost:8080/wf/script/async.js :: anonymous :: line 29"  data: no]

Could someone please help me about this..

Thanks,
Amit