I have a link which submits a POST request, and it was functioning well until I made some changes to my code, which as far as I'm aware have no bearing on this particular function. However, when I click my button I then receive the following error in console, and despite having looked into it, I'm not so sure how to rectify this, as it was working previously. I'd also like to understand the cause more.
Uncaught (in promise) TypeError: $(...).submit(...).then is not a function
In reference to this code:
$("#bugForm").submit((e) => {
e.preventDefault()
const input = document.getElementById('nameInput');
bugInfo = {
"name": `[${idTicket}] Bug report`,
"story_type" : "Bug",
"description": `+ ${data.ticket.brand.url}/agent/tickets/${idTicket}` + " \n" + `+ ${input.value}`,
}
reportBug(bugInfo).then(collapse.collapse('toggle'))
}).then(() => {
clearFields();
})
});
});
});
HTML:
<form id="bugForm" method="POST">
<textarea class="form-control" name="name" autocomplete="off" id="nameInput" rows="2"></textarea>
<div id="sendbutton">
<button type="submit" id="feedback-button" onclick="changeSecond();" class="btn btn-primary float-right">Send message</button>
</div>
</form>