扫码关注官方订阅号
初学node,如何编写数据接口,用以ajax交互呢?求demo或教程
小伙看你根骨奇佳,潜力无限,来学PHP伐。
可以看看Express或者koa 直接写nodejs的话的node
Express
koa
nodejs
node
下面的代码,ajax中的dataType修改成text,就能请求到
ajax
dataType
text
const http = require('http'); const hostname = '127.0.0.1'; const port = 1337; http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); });
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
可以看看
Express或者koa直接写
nodejs的话的node下面的代码,
ajax中的dataType修改成text,就能请求到