【发布时间】:2016-08-16 08:28:12
【问题描述】:
var app, express, fs, jquery, jsdom;
jsdom = require('jsdom');
fs = require('fs');
express = require('express');
jquery = fs.readFileSync('./jquery-2.0.3.min.js').toString();
jsdom.env({
html: '<html></html>',
src: [jquery],
done: function(errors, window) {
var $;
$ = window.$;
window.print = console.log;
console.log(errors);
return $.ajax({
url: "https://www.baidu.com",
type: "GET",
error: function(jqXHR, textStatus, errorThrown) {
return print(jqXHR.url + " " + jqXHR.status + " " + " " + textStatus + " " + errorThrown);
},
success: function(data, textStatus, jqXHR) {
return console.log(data);
}
});
}
});
app = express();
app.listen('3000', function() {});
我打算将一个项目迁移到 nodejs。 它使用 jquery ajax 与 https 后端通信。
上面的演示响应是:
location.replace(location.href.replace("https://","http://"));
如何在 nodejs&jquery ajax 中进行 https 调用
ps:如果我使用 nodejs+jquery ajax,我无法从 fiddler 获取任何包
【问题讨论】: