This ajax call will not execute the success or error function. The call itself works.
function myFunction() {
var Temp = document.getElementById("inputTemp").value;
var Light = document.getElementById("inputLight").value;
alert("Submitted");
$.ajax({
url: "Collector.php",
type: "POST",
data: {
inputTemp: Temp,
inputLight: Light
},
success: function() {
alert("yes");
},
error: function() {
alert("no");
}
});
}
You need to set the data type as json in ajax call.
Add dataType:'json'
$.ajax({
url:"Collector.php",
type:"POST",
dataType:'json',
data:{
inputTemp: Temp,
inputLight: Light
},
success:function(){
alert("yes");
},
error:function(){
alert("no");
}
})