How to run url from cronjobs with javascript code in my php file -
i have url , want execute url cronjobs. in php file there javascript code export highchart.
this code:
<script> $(function () { var options = { title: { text: 'daily chart', x: -20 //center }, exporting: { url: 'http://export.highcharts.com/' }, xaxis: { categories: [ 'a','b', ] }, yaxis: { title: { text: 'idr' }, }, tooltip: { valuesuffix: '°c' }, series: [{ showinlegend: false, name: 'daily', data: [ 1,2 ] }] }; var obj = {}, exporturl = options.exporting.url; obj.options = json.stringify(options); obj.type = 'image/png'; obj.async = true; var link=$.ajax({ type: 'post', url: exporturl, data: obj, datatype: 'html', context: document.body, global: false, async:false, success: function (data) { var result=exporturl+data; return result; } }).responsetext; $.ajax({ type: 'get', url: 'http://webserver2/index.php/report/render?link='+link+'&id=1', data: link, success: function (data2) { //alert(data2); } }); }); </script>
if execute in browser file highcart.png server. if execute in cronjobs nothing. body know how execute cronjobs??
javascript client-side language runs within browser. can use phantomjs run js server side. at: http://phantomjs.org/
edit:
download necessary package here. note these pre-compiled packages, assume using linux.
you save 'phantomjs' file in filesystem somewhere (that can access crontab).
save javascript .js file extension.
add cron job like:
30 08 10 06 * /path/to/phantomjs javscriptfile.js
this run 30 of june @ 8.30am (you need schedule when want.)
hopefully should work intended, although seem using jquery functions might need include jquery source code in .js file.
Comments
Post a Comment