简体   繁体   中英

How can I use Ajax with node.js with out using jQuery

I've been trying to use ajax with node.js , but it's like my server side node doesn't exist.

<script>
        testmessage = () => {
            xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET","../index.js", true);
            xmlhttp.send();
        }
</script>

This throws the following error:

index.js not found

I'm hosting the site locally using express and ejs
My index.js file is a directory above

我只需要将请求发送到localhost:3000因为它是服务器,而不是它下面的某个文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM