I am building website under subdomain. Site path is following: www.sub.example.com/site
In that folder I have functions.php which I use to fire up php functions.
$.ajax({
type: "POST",
url: "http://sub.example.com/site/functions.php",
data: {
action: 'sendData',
data: exampleData
},
success: function(data){
console.log(data);
}
});
For reasons unknown Chrome's console return:
POST http://sub.example.com/site/functions.php 500 (Internal Server Error)
send @ jquery-3.2.1.min.js:4
ajax @ jquery-3.2.1.min.js:4
(anonymous) @ main.js:35
dispatch @ jquery-3.2.1.min.js:3
q.handle @ jquery-3.2.1.min.js:3
I have double checked that function file has no errors.
Php file: here
I finally fixed it. Reason was I used wrong sql syntax. I was trying to update row's cert value by inserting new one. What I needed to do is just update the existing one with new value.
What I had:
$addAmount = $conn->prepare("INSERT INTO data (certs) VALUES (:newAmount) WHERE place = :place");
What I needed:
$addAmount = $conn->prepare("UPDATE data SET certs = :newAmount WHERE place = :place");
Thanks everyone for helping.