Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Run a .js file from a php script (not on the browser)

I am trying to run a .js file that is located on my web-page. I am using a cron-job, which triggers a php script, every hour. I do also have a javascript that checks for new posts on a forum. If there are any new post, it sends notifications to my iPhone app. The problem is that I can't trigger the .js file. Any suggestions?

2 Answers

Steven Parker
Steven Parker
229,608 Points

I still think you need to talk to the folks at cron-job.com. If they don't offer JavaScript on their server, what you want might not be possible. On the other hand, if they do, they should be able to give you instructions on how to use it.

But I have to wonder - why don't you run your JavaScript where your own web page is hosted?

Would it be possible to run the javascript file from the php if it was a nodejs?

Steven Parker
Steven Parker
229,608 Points

But do they have node.js installed on cron-job? What you run from their service must exist on their server.

Yes, but I am able to run a php-script, so I was wondering if it is possible to run javascript from the php-script (the php is located on my web-page)