jQuery-将表单提交到RESTful URL [英] jQuery - Submit Form to RESTful URL
本文介绍了jQuery-将表单提交到RESTful URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的想法已经100%空缺了,所以需要一些指导.
My mind has gone 100% blank on this so need some guidance please.
<form action="/" id="searchForm">
<input type="text" name="s" placeholder="Search...">
<input type="submit" value="Search">
</form>
我需要该表格,以便页面重定向到一个URL,例如
I need that form so the page redirects to a URL such as
http://example.com/rest/ful/url/{value of search}/
例如http://example.com/rest/ful/url/jQuery/
如果我搜索了jQuery
我什至需要jQuery吗?
Do I even need jQuery for this?
推荐答案
jquery解决方案:
Solution with jquery:
$('#searchForm').on('submit', function(event){
$('[name=s]').prop('disabled', true)
$(this).attr('action', 'http://example.com/rest/ful/url/' + $('[name=s]').val());
});
https://jsfiddle.net/3y4efht0/1/
这篇关于jQuery-将表单提交到RESTful URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文