/ नोड्स में / jquery ajax नहीं मिल सकता है / https के साथ पोस्ट - jquery, ajax, node.es, https

jjjj में ajax ajax को नहीं मिल सकता / https के साथ पोस्ट - jquery, ajax, node.js, https

    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() {});

मैं एक परियोजना को स्थानांतरित करने जा रहा हूं नोडज। यह https बैकएंड को संप्रेषित करने के लिए jquery ajax का उपयोग करता है।

उपरोक्त डेमो प्रतिक्रिया है:

location.replace(location.href.replace("https://","http://"));

मैं नोडज और jquery ajax में https कॉल कैसे कर सकता हूं

ps: अगर मैं नोडज + जेकरी अजाक्स का उपयोग करता हूं, तो मुझे फिडलर से कोई पैकेज नहीं मिल सकता है

उत्तर:

जवाब के लिए 0 № 1

हालाँकि, मुझे यह सुनिश्चित करने के लिए jQuery और jsDom का उपयोग करना संभव नहीं है, लेकिन इसके लिए बहुत अधिक आजमाए गए और सच्चे पुस्तकालय हैं। उदाहरण के लिए, कई नोड डेवलपर्स का उपयोग करते हैं पुस्तकालय का अनुरोध करता है

तो इसके बजाय

$.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);
}
});

तुम करोगे:

request(
uri: "https://www.baidu.com",
method: "GET",
function(err, res, body){
// handle the err and do what you want with the response
});