I am building a widget. The app has to be run locally on the device but needs PHP. I have a web server that has the PHP files and when the whole widget is just put on the server it works fine but when its locally run I can't call the PHP files using ajax. How do I call serverside PHP from locally hosted JavaScript
When you just open your HTML files locally, AJAX requests will be prevented. See here: Ajax in Jquery does not work from local file
You can spin up a local web server and then it should work, but there may be a better solution. What exactly are you trying to archieve? Should it be more like an application?