简体   繁体   English

当我单击“计算”按钮时,它如何获取每个A,B框中的值,并将这些值传递给服务器以计算结果并发出Alert()?

[英]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.

相关问题 单击按钮时如何将多个值传递给对话框 - How can I pass multiple values to dialog box on button click 当我单击下面给出的代码中的计算按钮时,有人可以帮助我如何更改添加到输入框中的伪跨度的颜色 - Can someone help me how to change the color of pseudo span added to the input box when I click on calculate button in code given below 如何获取.click按钮以隐藏警报框 - How to get a .click button to hide an alert box 当我得到带有 $this 的 select 框时,如何计算选项标签的数量 - how can I calculate number of options tag when I get the select box with $this 如何获得 2 个输入的值,计算它们并将结果放入另一个 - How can I get the value of 2 inputs, calculate them and put the result in another 如果我单击选择按钮并在文本框中传递其值,如何获得所选单选按钮的值? - how can i get the value of selected radio button if i click the select button and pass its value in a textbox? 单击“确定”时从数据库获取值的jquery警报框 - jquery alert box when click “OK” get the values from database 单击“提交”按钮时如何在JavaScript警报中回显复选框 - How to echo Check Box in JavaScript Alert When Click on Submit Button 除非用户单击特定的按钮,否则如何向用户显示警报框 - How can I display alert box to users unless they click a specific button 如何通过单击将按钮的值添加到文本框? - How can I add the value from button to the text box by click?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM