With that code, i just got the error:
“Error: Can’t find variable: $http
loadGroups@httlp://localhost:8100/js/controller.js:19:8
httlp://localhost:8100/js/controller.js:17:12
…”
works fine.
but now i see the whole code of the “load_Groups.php” in the console and not just the ECHO.
I don’t need to stringify the data, because i return an JSON-array.
This is the end of the “load_Groups.php”:
And it returns me the whole code/content of the PHP-file.
But when i just open die PHP-file in browser, i see the correct output…
You are requesting a local PHP file.
PHP must be run on a web server, IonicFramework runs using Javascript, PHP won’t be installed.
What you need to do is to run a apache2 server. This can not be done on the phone, it must be hosted elsewhere. You can then query that server for the data.
It looks like I’m requesting a local file, but Ionic is installed on a virtual server.
I use Ionic on my MacBook via MAMP.
The path in safari-adressbar is like that:
“locahost:8100/#/tab/dash”
The reason it requires a absolute url is because if you call a PHP file via a relative url, it is not being called through the server, The computer doesn’t know how to use it. Therefore, it runs as though it was a text file.
You will need the PHP to be hosted on a server with PHP and MySQL installed.
Only then will you be able to request it.
Say your PHP is hosted on http://www.example.com/
If you call that it will work.
Although say this URL is hosted locally, you could access it with http://localhost/example/.
This is the only way that PHP will run.
Calling it via /var/www/example/ will request the PHP file but will not run through apache2 or nginx (depending on the software used to run the webserver), therefore not executing the code and resulting in plain text displaying.
Although, when hosting it on http://localhost/example, Only your computer will be able to access this, (this is fine for browser based testing, but when you move to testing on a device, you will either need to host it on a webserver or use your IP.