javascript
html 抓取 post 请求,javascript – 获取html form post方法的返回值 -凯发k8官方网
您需要发出ajax请求.虽然不是绝对必要,但我建议你使用
jquery,它会让事情变得容易多了.另请看这个问题:
jquery ajax submit form
这是mason的一个小例子,它当然非常简化,你应该添加一些错误检查和一些转义,但我认为这可能是一个好的开始.您的a.mc组件可能如下所示:
this is a$(document).ready(function() {
$("#myform").submit(function() { // intercepts the submit event
$.ajax({ // make an ajax request
type: "post",
url: "b", // it's the url of your component b
data: $("#myform").serialize(), // serializes the form's elements
success: function(data)
{
// show the data you got from b in result div
$("#result").html(data);
}
});
e.preventdefault(); // avoid to execute the actual submit of the form
});
});
它只是一个加载jquery库并包含表单的html页面,它包含一些代码,用于指示表单在用户单击submit按钮时向b组件发出ajax请求,然后显示b组件返回的内容你的结果div.
这可能是你的b.mc组件:
has 'mytext';
%class>
i got this text from your form,
and its length is .
结果将是这样的:
总结
以上是凯发k8官方网为你收集整理的html 抓取 post 请求,javascript – 获取html form post方法的返回值的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: