I am new in Ionic,Apahce Cordova and I created a simple application which has static list view items but I want to get data from MYSQL table and replace this in my static list. I Google it some one worked on it but I don't know where I should put my php files and I created some php files in Ionic app/www/php files but it doesn't work for me and what is your solution guys? Thank you
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
As said above, your PHP files should be hosted on a webserver. And since the resource is not local to your application, you will need $http.jsonp, which allows CORS.
Here's an example of how you'd send a request to a PHP page in AngularJS.
OR
For sending requests using jQuery, you can refer this post: https://stackoverflow.com/a/28740155/4412363
Now, you can
$_GET
the data, then you must have the response in JSONP, also you need to add the callback in your response. It'll look like:PS: Here, Ionic takes care of the IPs when you're trying on an emulator. So I just set the url's domain to my local IP address, and it works on all the devices (desktop, emulator, and mobile)
You can put your php files in localhost or live server.I had the same problem (Cross-Origin Request Blocked) when the app is run in browser.Here are solutions from my experience
1.Test the app in emulator not in browser and change the localhost address to this
http://10.0.2.2/test/test.php
.This will works fine for me2.if you are run in android device you cant access from the localhost,so put the files in a live server eg:
http://www.testapp.in/test/test.php