找不到XMLHttpRequest错误

时间:2017-06-05 13:43:00

标签: javascript jquery xml xmlhttprequest aiml

这是我的代码:

<?xml version="1.0" encoding="UTF-8"?>
<aiml version="1.0.1" encoding="UTF-8"?>

<category>
    <pattern>BOTÃO</pattern>
    <template>
        &lt;button id="ajaxButton" type="button"&gt;Clique aqui&lt;/button&gt;
        <script>
            $(document).ready(function(){
                document.getElementById("ajaxButton").addEventListener('click', loadXML);
            });


            function loadXML(){
                try{
                        var xRequest = new XMLHttpRequest();

                        xRequest.onreadystatechange = function(){
                            //Se o open-send funcionar e estiver ok, roda essa função.
                            if( xRequest.readyState == 4 ){
                                if(  xRequest.status == 200 ){
                                    console.log("Deu tudo certo.");
                                    console.log(xRequest.responseText);
                                }
                            }
                            else{
                                console.log("Ocorreu um erro durante o open-send.");
                                console.log("readyState = " + xRequest.readyState.toString());
                                console.log("status = " + xRequest.status.toString());
                                console.log(xRequest.statusText);
                            }
                        };
                        xRequest.open("GET", "http://penta3.ufrgs.br/~aliane/getuser.php", true);
                        xRequest.send();
                    }
                    catch(Exception erro){
                        console.log("Erro ocorrido: " + erro);
                    }
            };
        </script>
    </template>
</category>


</aiml>

当我在页面上运行脚本时,出现此错误:

VM244:1 Uncaught SyntaxError: Unexpected end of input
at p (jquery-3.2.1.min.js:2)
at Ja (jquery-3.2.1.min.js:3)
at r.fn.init.append (jquery-3.2.1.min.js:3)
at r.fn.init.<anonymous> (jquery-3.2.1.min.js:3)
at T (jquery-3.2.1.min.js:3)
at r.fn.init.html (jquery-3.2.1.min.js:3)
at Object.success ((index):78)
at i (jquery-3.2.1.min.js:2)
at Object.fireWith [as resolveWith] (jquery-3.2.1.min.js:2)
at A (jquery-3.2.1.min.js:4)

我一遍又一遍地读了我的文件,找不到输入的意外结束的地方.. 将我的Jquery更新到最新版本,只是为了确定(3.2.1),但没有成功......

目标是从正在开发的ChatBot调用此脚本,当它键入“botão”时,调用脚本并... 任何想法?

0 个答案:

没有答案