I noticed that the browsers have a large effect on how the AJAX code is supported. Does anyone have any idea why this code will work in Firefox and IE11, but not Chrome or IE10? I get an error response of 0 using IE10. I think Chrome just doe snot support AJAX extensions from local files.
function poll(){
// Construct an ajax() GET request.
// http://www.w3schools.com/jquery/ajax_ajax.asp
console.log(“Poll called”)
$.ajax({
type: “get”,
cache: false,
jsonp: false,
//crossDomain:true,
//processData: false,
url: “https://agent.electricimp.com/”+externalURL, // URL of our imp agent.
dataType: “json”, // Expect JSON-formatted response from agent.
success: function(agentMsg) { // Function to run when request succeeds.
// jQuery find "pin1" id and overwrite its data with "pin1" key value in agentMsg
$("#pin1").html(agentMsg.input1);
$("#pin2").html(agentMsg.input2);
$("#vin").html(agentMsg.voltage);
$("#out1").html(agentMsg.out1);
$("#out2").html(agentMsg.out2);
// updateBG(agentMsg.pin5); // Try this if you have a photocell connected to pin 5
console.log("OK")
},
error: function(err) {
console.log("err = " + err.status)
}
});
}