Onclick event -
<button id="button-send" onclick="SendToOrderPhp.send()" class="button-on-form">Send</button> I want to pass to a function inside the class. And then the question is a static function - if I try to call a function, the class constructor will not do the work?
How to be in this case? Thank.
The code itself:
class SendToOrderPhp{ private let name_; private let email_; constructor(let name, let email){ this.name=name; this.email=email; } static function send(){ fetch('/php/order.php',{ method: 'post', headers: { 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json' }, body: JSON.stringify({ name: name_, email: email_ }) }); } } SendToOrderPhp(GetInputsFromHtml.getName, GetInputsFromHtml.getEmail); SendToOrderPhp.send();
nameandemailvalues themselves. - Regent