Select to view content in your preferred language

JavaScript XMLHTTP Post

759
4
Jump to solution
05-04-2023 01:00 PM
JohnLucotch2
Frequent Contributor

Can Survey 123 support XMLHTTP Post?  

 

Thanks

0 Kudos
1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

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. 

Thank you,
Zach

View solution in original post

4 Replies
ZacharySutherby
Esri Regular Contributor

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. 

Thank you,
Zach
JohnLucotch2
Frequent Contributor

Thanks that is what I was missing.

 

0 Kudos
BigLouC
Frequent Contributor

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.

0 Kudos
BigLouC
Frequent Contributor

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");

0 Kudos