【笔记】Nodejs中使用jQueryAJAX

前言

Nodejs中使用jQueryAJAX,允许跨域访问

下载依赖

1
npm install ajax-for-node

发送AJAX请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const nodeAjax = require('ajax-for-node');

nodeAjax({
url: "https://echo.apipost.cn/get.php",
data: formData,
type: "POST",
processData: false,
contentType: false,
success: function (data, status, xhr) {
console.log(data, status, xhr)
},
error: function (xhr, status, error) {
console.log(xhr, status, error)
},
complete: function (xhr, status) {
console.log(xhr, status)
}
});

完成

参考文献

Apipost-Team/nodeajax