简体   繁体   English

如何在不使用 jQuery 的情况下将 Ajax 与 node.js 一起使用

[英]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.我一直在尝试将 ajax 与node.js一起使用,但就像我的服务器端节点不存在一样。

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

This throws the following error:这会引发以下错误:

index.js not found找不到 index.js

I'm hosting the site locally using express and ejs我使用expressejs在本地托管站点
My index.js file is a directory above我的 index.js 文件是上面的一个目录

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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