Hello @JohnLucotch2,
You can send a POST request using xmlhttp in a custom JavaScript function. The important thing to note is asynchronous calls are not supported so you will need to set the async parameter to false when making the request.
Hello @JohnLucotch2,
You can send a POST request using xmlhttp in a custom JavaScript function. The important thing to note is asynchronous calls are not supported so you will need to set the async parameter to false when making the request.
Thanks that is what I was missing.
Any chance you can share the code you are using. I am having a hard time achieving the same and have no luck finding samples. Thanks.
I get all that teach a man to fish, but for those of us in a bind, here is the code:
function settime(objectid, schedulechange, mtoken){
let layerURL = `https://services.arcgis.com/`;
let formParams = `f=json&rollbackOnFailure=true&token=`+ mtoken +`&features={
"attributes": {
"OBJECTID":` + objectid + `,
"Instructions":` + schedulechange + `
}
}`
let http = new XMLHttpRequest();
http.open("POST", layerURL, false);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
//Call a function when the state changes.
http.onreadystatechange = function() {
if (http.readyState == 4 && http.status == 200) {
console.log(http.responseText);
}
};
http.send(formParams)
console.log("Layer done");