简体   繁体   English

AJAX 在节点 js 上找不到回调 404 错误

[英]AJAX callback 404 not found error on node js

When I run the code with nodejs, ajax on html gives 404 error.当我使用 nodejs 运行代码时,html 上的 ajax 给出 404 错误。 When I run the html page on the live server without nodejs, I don't see a problem with ajax.当我在没有 nodejs 的实时服务器上运行 html 页面时,我没有看到 ajax 有问题。 So ajax is normal but running with node js its not working.所以 ajax 是正常的,但是用 node js 运行它不起作用。 xml file not available because when I give different xml file to ajax, problem is going. xml 文件不可用,因为当我将不同的 xml 文件提供给 ajax 时,问题就来了。 i think when the html file is run through nodejs it cannot display the xml file.我认为当 html 文件通过 nodejs 运行时,它无法显示 xml 文件。 enter image description here enter image description here在此处输入图像描述 在此处输入图像描述

I solved:D.我解决了:D。 I didnt take xml file with express modüle.我没有使用 express 模块获取 xml 文件。 And I added server side this code.我在服务器端添加了这段代码。

app.get('/savee.xml', function(req, res){ res.sendFile(__dirname + '/savee.xml'); });

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

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