当前位置:网站首页>Express WEB服务器的简单使用
Express WEB服务器的简单使用
2022-07-27 18:08:00 【逍码农】
// 引入express
const express=require("express");
// 创建一个express服务器
const app=express();
//设置请求的路径与方式,请求成功后执行回调函数
app.get('/server',(request,response)=>{
// 设置响应头,解决跨域
response.setHeader('Access-Control-Allow-Origin','*')
// 设置响应体
response.send("hhhh")
})
// 启动服务
app.listen(9000,()=>{
console.log("服务器已经启动了,端口9000监听中....")
})在发送AJAX的时候设置url参数的方法
app.get('/server',(request,response)=>{})
//在地址栏理设置参数
//在server后面用问号传递 多个参数用&隔开针对AJAX发送请求会出现缓存的问题
我们在请求的路径后面加一个时间戳 例如'127.0.0.1:8080/server?t='+Data.now()
关于AJAX请求超时,我们要在前端设置一个超时设置
//超时设置为2s,就是如果请求2s还没有请求到,就取消请求
xhr.timeout=2000
//我们还可以设置一个请求超时的回调
xhr.ontimeout=function(){}
//网络异常的回调
xhr.οnerrοr=function(){}
边栏推荐
- vi工作模式(3种)以及模式切换(转换)
- [design tutorial] yolov7 target detection network interpretation
- Mlx90640 infrared thermal imager temperature sensor module development notes (VII)
- 用户和权限修改用户密码
- 技术博客及教程
- RK3399平台开发系列讲解(进程篇)15.36、理解进程和协程
- User and authority modify user password
- EasyCVR平台添加RTSP设备时,出现均以TCP方式连接的现象是什么原因?
- Management of user organization structure
- 做测试, 就得去大厂,内部披露BAT大厂招聘“潜规则”
猜你喜欢

Data warehouse construction - DWD floor

未定义变量 “Lattice“ 或类 “Lattice.latticeEasy“(Matlab)

Flask-MDict搭建在线Mdict词典服务

Write bootloader from 0

【程序人生】“阶段总结“-不甘平凡

Understand the wonderful use of dowanward API, and easily grasp kubernetes environment variables

Introduction to JVs Foundation
![(manual) [sqli labs38, 39] stack injection, error echo, character / number type](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
(manual) [sqli labs38, 39] stack injection, error echo, character / number type

2022-07-19 advanced network engineering (XX) BGP route optimization, route optimization analysis one by one

MySQL驱动jar包的下载--保姆教程
随机推荐
It is said that Intel will stop the nervana chip manufactured by TSMC at 16nm
To do the test, you have to go to the big factory and disclose the "hidden rules" of bat big factory recruitment internally
JVM overview and memory management (to be continued)
Introduction to JVs Foundation
MySQL驱动jar包的下载--保姆教程
Passive income: return to the original and safe two ways to earn
Knowledge dry goods: basic storage service novice Experience Camp
Analysis on the optimization of login request in IM development of instant messaging mobile terminal
关于栈迁移的那些事儿
[Alibaba security × ICDM 2022] 200000 bonus pool! The risk commodity inspection competition on the large-scale e-commerce map is in hot registration
CONDA common commands
Koin simple to use
如何监控NVIDIA Jetson的的运行状态和使用情况
JVs privatization deployment start failure handling scheme
JVS私有化部署启动失败处理方案
Some contents related to cmsis-rtos
MySQL 日志查询日志
[design tutorial] yolov7 target detection network interpretation
金仓数据库 Oracle至KingbaseES迁移最佳实践(2. 概述)
金仓数据库 KingbaseES异构数据库移植指南 (3. KingbaseES移植能力支撑体系)