javascript - 使用 POST 方法 jquery 发送表单中字段的内容

标签 javascript jquery get

我遇到了这种情况,这是我目前的 HTML 页面:

<form id="Form" label="Dati" name="Dati" title="Dati" visible="true" method="post" action="land.htm">
<h1>DATI</h1>
    <label class="label" for="campoA">
   <input type="text" id="campoA" class="fieldSet" style="width: 102px"/><label>  Campo A</label>
    <input type="text" id="campoB" class="fieldSet" style="width: 102px"/><label>  Campo B</label>
    <input type="button" id="send" value="Trasmetti" class="fieldSet"/>
</form>

单击按钮时,我需要将这两个文本输入的内容(值)发送到另一个 html 页面。我查看了我在网上找到的许多解决方案,但我对此很陌生,无法完成我的任务。任何人都可以向我提供 javascript/jquery 中正确的分步代码吗?

提前致谢

最佳答案

    <!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#send").click(function(){
        $.post("demo_test_post.asp",
        {
          campoA: $('#campoA').val(),
          campoB: $('#campoB').val()
        },
        function(data,status){
            alert("Data: " + data + "\nStatus: " + status);
        });
    });
});
</script>
</head>
<body>

<form id="Form" label="Dati" name="Dati" title="Dati" visible="true" method="post" action="land.htm">
<h1>DATI</h1>
    <label class="label" for="campoA">
   <input type="text" id="campoA" class="fieldSet" style="width: 102px"/><label>  Campo A</label>
    <input type="text" id="campoB" class="fieldSet" style="width: 102px"/><label>  Campo B</label>
    <input type="button" id="send" value="Trasmetti" class="fieldSet"/>
</form>

</body>
</html>

关于javascript - 使用 POST 方法 jquery 发送表单中字段的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29030944/

相关文章:

javascript - 动画 Jquery 的问题

javascript - 获取窗口高度并将 div 大小设置为该高度

javascript - 使用 css 或 javascript 中的媒体查询更改 svg 文本的 x-y 坐标?

jquery - 保留 jquery 链的空函数

python - Django从get方法获取数据并传递给post方法

javascript - 在 asp.Net LinkBut​​ton OnClientClick 上触发 html5 表单验证

javascript - 使用 JavaScript 循环全年而不显示时间

java - SOAP POST 方法执行 GET?

当参数相同时,PHP password_verify 返回 NULL

javascript - React - 内联动态组件样式未在MouseOver和onMouseOut事件上更新