Script代码中xhr.open("GET", URL, true)说open is not a function

function ftn_button_clicked(){
              xhr = new createXHR();
                //var url="\PointGenerate";
                xhr.open("GET", "PointGenerate.java", true);          
                xhr.send();
                xhr.onreadystatechange = ajaxComplete;   
        }
        function ajaxComplete(){
            if(xhr.readyState === 4 && xhr.status === 200){
                    document.getElementById("txt1").innerHTML.value = xhr.responseText;
                    var num = xhr.responseText;
                    window.alert("good");
                    plotrandom(num); 
            }
        }
		  
       function createXHR(){
           if(window.XMLHttpRequest){
               xhr = new XMLHttpRequest();
               //window.alert("111"); check working or not
           }
           else{
               xhr = new ActiveXObject("Microsoft.XMLHTTP");
               //window.alert("1111");
           }

用游览器打开网页后,按按钮没反应, 就F12查看属性,游览器报错是这open那句话。 说is not a function. 

慕婉清3727629
浏览 8688回答 2
2回答

yinyun

说明你没有正确初始化一个XMLHttpRequest对象

amorlova

xhr没有定义吧
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript