Using Javascript. I'm getting an error when the onclick of a button fires (by pressing the button). The error is:
Uncaught TypeError: accept is not a function at HTMLInputElement.onclick
Here's the HTML of the button (and its neighbour):
<input type="button" value="Accept Offer" onclick="accept()" />
<input type="button" value="Cancel" onclick="cancelAccept()" />
The Cancel button works fine.
Here's the accept JS function:
function accept() {
//check that user logged in
api.me()
.then( (res) => { //logged in, accept offer
acceptOffer(res.user);
}, (err) => {
console.log("error:",err);
alert("Authentication error. Please logout and in again");
cancel();
});
}
The javascript is imported(?) in the head tag at the top of the html page.
api.me() is a call to a library.
It seems the name accept is causing trouble. See this jsfiddle.
Rename your function and put it in the global scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With