admin管理员组文章数量:1418103
What I want to do is make a POST request with arbitrary params, much like submitting a form. That is not merely doing the XHR. What I ideally want is to emulate a submit (like submiting a form, not POSTiing and then redirecting). I want to avoid the latency of $.post + window.top.location = blah
The most direct way would be to have a 'fake' form and insert a bunch of elements, then serialize and use jQuery.submit(), something like Is there a way using jQuery to submit a form without the elaborate field by field breakdown?
I wish there were a more elegant way.
My use case is that I am gathering a bunch of random fields through external API calls (from Facebook and other services) and want to submit ALL that info at once to user creation, as if the user filled out all this information and pressed 'submit'
Any suggestions? Thanks!
What I want to do is make a POST request with arbitrary params, much like submitting a form. That is not merely doing the XHR. What I ideally want is to emulate a submit (like submiting a form, not POSTiing and then redirecting). I want to avoid the latency of $.post + window.top.location = blah
The most direct way would be to have a 'fake' form and insert a bunch of elements, then serialize and use jQuery.submit(), something like Is there a way using jQuery to submit a form without the elaborate field by field breakdown?
I wish there were a more elegant way.
My use case is that I am gathering a bunch of random fields through external API calls (from Facebook and other services) and want to submit ALL that info at once to user creation, as if the user filled out all this information and pressed 'submit'
Any suggestions? Thanks!
Share Improve this question edited May 23, 2017 at 12:04 CommunityBot 11 silver badge asked Nov 25, 2011 at 7:56 ambertchambertch 7,6495 gold badges31 silver badges42 bronze badges1 Answer
Reset to default 5yes
you can use $.ajax (example)
or $.post and $.get ... example:
$.post(
"url_to_page",
/* string like this: "text=me%20man&[email protected] or an object": */
{text: "me man", mail: "[email protected]"}
)
/* you can check if the request was submitted successfully */
.success(function(data) {
alert("Success!");
alert(data); //data on page
})
/* you can check if the request failed */
.error(function() {
alert("Error!");
});
本文标签: javascriptIs there a way to submit a quotfakequot form using jQueryStack Overflow
版权声明:本文标题:javascript - Is there a way to submit a "fake" form using jQuery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745281984a2651475.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论