Hi I'm totally new to web developemnt. I have a html file, which contains angularJS code, and which calls a .php file. Both on my local folder.
I have searched online, but:
Install server is not an option because this is going to be used by others as well. And we don't have admin permission on our own machine.
I tried '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" - -allow-file-access-from-file file:///C:/Users/ella/Test/eClerkUpdateURL/index2.html' and still get same error
What are my options here? 1) creating an api with that PHP code? 2) Put the code to another application server , and add the folder to IIS? 3) Just use AngujarJS to write the database update part so that there is no need to call another script?
Code:
<!DOCTYPE html>
<!-- index.php !-->
<!-- https://www.webslesson.info/2016/09/angularjs-tutorial-with-php-insert-data-into-mysql-database.html !-->
<html>
<head>
<title>Database Update Tool</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body>
<br /><br />
<div class="container " style="width:300px;">
<h3 align="center">Database Update Tool</h3>
<div ng-app="myapp" ng-controller="usercontroller">
<label>Table Name</label>
<input type="text" name="firstname" ng-model="firstname" class="form-control" />
<br />
<label>Condition Name</label>
<input type="text" name="lastname" ng-model="lastname" class="form-control" />
<br />
<input type="text" name="condition_name" ng-model="condition_name" class="form-control" />
<br />
<input type="Search" name="search_button" class="btn btn-info" ng-click="insertData()" value="Search"/>
</div>
</div>
</body>
</html>
<script>
var app = angular.module("myapp",[]);
app.controller("usercontroller", function($scope, $http){
$scope.message = $scope.firstname
$scope.insertData = function(){
$http.get(
"Search.php",
{'firstname':$scope.firstname, 'lastname':$scope.lastname}
).success(function(data){
alert(data);
$scope.firstname = null;
$scope.lastname = null;
});
}
});
</script>
Error: Access to XMLHttpRequest at 'file:///C:/Users/jy70606/Test/eClerkUpdateURL/Search.php' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.