[英]When I click the “Calculate” button, how can it get the values in each box A,B and pass those value to server to calculate and alert() the result?
I want to do a simple sum calculation GUI. 我想做一个简单的总和计算GUI。 The website will prompt the user input variable A,B and send to server ( c++ file will do the job ) to calculate and A+B return result by alert().
网站将提示用户输入变量A,B并发送到服务器(c ++文件将完成此工作),并通过alert()返回A + B返回结果。
I have 2 input boxes "variable A" and "Variable B". 我有2个输入框“变量A”和“变量B”。 When I click the "Calculate" button, how can it get the values in each box A,B and pass those value to server to calculate and alert() the result?
当我单击“计算”按钮时,它如何获取每个A,B框中的值,并将这些值传递给服务器以计算结果并发出alert()? I am using js and react-bootstrap to develop the website.
我正在使用js和react-bootstrap开发网站。
You need to do some kind of XMLHttpRequests as mentioned above. 您需要执行如上所述的某种XMLHttpRequests。 You could choose any one of the many XHR libraries out there or use the Fetch API
您可以选择许多XHR库中的任何一个,也可以使用Fetch API
You can refer to the following link to better choose a particular solution according to your needs. 您可以参考以下链接 ,根据需要更好地选择特定的解决方案。
You might want to look into Axios , on how to post data to your server. 您可能需要研究Axios ,以了解如何将数据发布到服务器。
You'll have to make XMLHttpRequests from the browser to your server. 您必须将XMLHttpRequests从浏览器发送到服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.