[英]Post data from a form in json format
I have two html pages: 1.html
and 2.html
.我有两个 html 页面:
1.html
和2.html
。 I want to post data from a form in 1.html
to 2.html
.我想将数据从
1.html
的表单发布到2.html
。 I want to store data from form in 1.html
in json and then post it to 2.html
without going to 2.html
when I click on submit button and parse json in 2.html
and use them.我想将表单中的数据存储在 json 中的
1.html
中,然后当我单击提交按钮并在2.html
解析 json 并使用它们时,将其发布到2.html
而不会转到2.html
。
Contents of 1.html
: 1.html
内容:
<body>
<form action="2.html" method="POST">
<input type="text" name="material" value="material" readonly>
<input type="text" name="Unit" value="Unit" readonly>
<button type="submit" id="add">add</button>
</form>
</body>
Can anyone help?任何人都可以帮忙吗? I need it soon.
我很快就需要它。 thanks
谢谢
$.post("your_backend_api.as", {suggest: txt}, function(result){
$("span").html(result);
});
above {suggest : txt} is your json object.上面的 {suggest : txt} 是你的 json 对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.