0

I wanted to schedule sending of report(chart made by javascript) via email in a weekly basis. To have that, I need to convert first the chart(made by javascript) to image using php(AJAX) and upload to the server then send it.

I'm already using node.js in my server but ajax doesn't work there. Is there's any way to get the same goal I want?


ReferenceError: XMLHttpRequest is not defined I got this error in the terminal.

Is there any error in my code?

var CronJob = require('cron').CronJob; new CronJob('10 * * * * *', function() {

ajax_request=new XMLHttpRequest;
ajax_request.onreadystatechange=function(){
    if(ajax_request.readyState==4&&ajax_request.status==200){
         console.log('You will see this message every second');
    }
};
ajax_request.open("GET","http://domain.com/test.php",true);
ajax_request.send();

}, null, true, 'Asia/Manila');

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Gige
  • 23
  • 6

1 Answers1

0

Why would ajax not work with node.js? AJAX simply sends data with javascript via the HTTP protocol, it does not have any restrictions in regards to which backend setups it works with, as long as they support the HTTP protocol.

You can generate the image with node.js, you dont have to use PHP

  • ReferenceError: XMLHttpRequest is not defined I got this error in the terminal. Is there any error in my code? var CronJob = require('cron').CronJob; new CronJob('10 * * * * *', function() { ajax_request=new XMLHttpRequest; ajax_request.onreadystatechange=function(){ if(ajax_request.readyState==4&&ajax_request.status==200){ console.log('You will see this message every second'); } }; ajax_request.open("GET","http://domain.com/test.php",true); ajax_request.send(); }, null, true, 'Asia/Manila'); – Gige Aug 13 '15 at 11:02
  • If yu know hot to generate image from data image base64 to node.js please share. I would appreciate that. – Gige Aug 13 '15 at 11:09
  • http://stackoverflow.com/questions/22687939/creating-image-from-base64-string-in-nodejs –  Aug 13 '15 at 11:11