Mr_Tib
09/21/2022, 3:52 PM<script>
var url = '';
$.ajax({
contenType: "application/json; charset=utf-8",
data: {
"key1": "some value",
"key2": 'some value'},
type: "POST",
dataType: "json",
url: 'URL HERE',
success: function(data,status,xhr){
console.log(data);
if(data.error != undefined && data.error != ""){
window.alert("Error: " + data.error);
}else{
if(data.valid){
console.log(data);
window.alert(data.id);
}
}},
error: function(xhr,status,error){
window.alert(error);
}
});
</script>
rmhollands
09/21/2022, 3:57 PMMr_Tib
09/21/2022, 4:01 PMalien4u
09/21/2022, 4:23 PMMr_Tib
09/21/2022, 4:54 PMShawn Talbert
09/21/2022, 7:14 PMpromise
version - just <http://https.post|https.post>
should be simpler and perform equally.Mr_Tib
09/21/2022, 8:45 PM<http://https.post|https.post>
instead of promise
and it did work. I'm confused, I thought it wouldn't work. When I tried using Postman to send a POST request it failed so I figured... "Oh, it's an AJAX request so I should use promise
when doing this from NetSuite"alien4u
09/21/2022, 8:46 PMMr_Tib
09/21/2022, 8:47 PMpromise
version because I need to save the response in a custom record.Shawn Talbert
09/21/2022, 8:47 PMpromise
version would only be needed if async behavior were needed, but that's not usually very useful for server-side scripts.Shawn Talbert
09/21/2022, 8:49 PMpromise
flavor for some reason, be sure to remember to handle errors