I am just studying ionic and I’m stacking with this almost a week. what i want is to access the data from localhost
------------------------------------------------------------connecting.php---------------------------------------------
//located at htdocs/xampp/mangkanor-ajax/connecting.php
<?php $fstname = mysql_real_escape_string($_POST['fstname']); $lstname = mysql_real_escape_string($_POST['lstname']); mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("dummy") or die(mysql_error()); mysql_query("INSERT INTO dummy_data (names) VALUES ('$fstname')"); Print "Your information has been successfully added to the database."; ?>**-----------------------------------------------------------------------------------App.js---------------------------------------------------
.controller(“HttpController”, function($scope,$http){
$scope.getdata = function()
{
$http.post("http://localhost:80/dummy/connecting.php", {'fstname': 'hahaha', 'lstname': 'hahaha'})
.success(function(data, status, headers, config){
console.log("inserted Successfully" + data);
$scope.firstname = data.fstname;
$scope.lastname = data.lstname;
})
.error(function(data) {
alert("error");
});
}
});
--------------------------------------------------------------------index.html---------------------------------------------------------------------
<ion-content ng-controller = "HttpController">
<button class = "button" ng-click="getdata()">send</button>
<br>
name: {{firstname}} {{lastname}}
</ion-content>
i’m accesing it through genymotion emulator. and i always get an alert Error!