I send data from one server to another with XMLhttpRequest but this code doesn't work:
var AjaxURL = 'http://localhost:5000/index.html';
$.ajax({
type: "GET",
url: AjaxURL,
data: {
foo: "test01"
},
success: function(result) {
window.console.log('Successful');
}
});
(Console log: "Successful") I have tried it with an iframe and it works but I need to send it with ajax or XMLhttpRequest.
const socket = io();
let params = new URLSearchParams(location.search);
let a1 = params.get('foo');
socket.emit('data', a1);
socket.on('data', (data) => {
const fileName = './src/data.json';
const file = require(fileName);
file.data = data;
fs.writeFile(fileName, JSON.stringify(file), function writeJSON(err) {
if (err) return console.log(err);
console.log('writing to ' + fileName + ':' + data);
});
})
{"data":"testing"}
Thanks