Hello forum:
I'm looking for someone smarter than me. This javascript async function is failing with a syntax error I think. I can't find what it is. Maybe someone else can I hope.
async function AJAX(msg) {
var url = "https://dev.orange-traffic-cones.com/mm5/TestProgram.php";
try {
var response = await fetch(url,
{ method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'private, no-cache, no-store, must-revalidate'
},
body: msg
}
);
if (response.ok) {
const result = await response.text();
quote_resp(result);
} else {
console.error(`An error occurred, status: ${response.status}`);
}
}
catch (error) {
if (error instanceof TypeError) {
console.error('Network error:', error);
} else {
console.error('Other error:', error);
}
}
}
I'm looking for someone smarter than me. This javascript async function is failing with a syntax error I think. I can't find what it is. Maybe someone else can I hope.
async function AJAX(msg) {
var url = "https://dev.orange-traffic-cones.com/mm5/TestProgram.php";
try {
var response = await fetch(url,
{ method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'private, no-cache, no-store, must-revalidate'
},
body: msg
}
);
if (response.ok) {
const result = await response.text();
quote_resp(result);
} else {
console.error(`An error occurred, status: ${response.status}`);
}
}
catch (error) {
if (error instanceof TypeError) {
console.error('Network error:', error);
} else {
console.error('Other error:', error);
}
}
}
Comment