简体   繁体   English

JS:直接过帐表格

[英]JS: Posting form directly

If on document.ready, I want my form to auto post itself, is this possible? 如果在document.ready上,我希望表单自动发布,这可能吗?

So when the document has loaded, then it posts itself and takes to the action="" (in this case is ?upload=true). 因此,在文档加载后,它会自行发布并执行action =“”(在本例中为?upload = true)。

I heard about $.post() jquery, but this is just for posting in the background? 我听说过$ .post()jQuery,但这只是用于后台发布?

$.post() is an AJAX call and will not force the entire page to postback. $ .post()是AJAX调用,不会强制整个页面回发。

you may want to try 你可能想尝试

$(document).ready(function(){
     var form = $("#yourformid");
     form.submit();
});

Yes, $.post() in jQuery is for POST requests with AJAX. 是的,jQuery中的$.post()用于AJAX的POST请求。

If you want a form to submit on the document ready event, just invoke the submit itself! 如果您希望表单在文档准备事件中提交,只需调用提交本身即可!

$(document).ready( function()
{
  $('form').submit()
});

You want something like this: 您想要这样的东西:

$(function() {
  $('#myformid').submit();
});

See the documentation for jQuery's submit() . 请参阅jQuery的submit()文档

And see this working demo: http://jsfiddle.net/8hg8s/ 并查看此工作演示: http : //jsfiddle.net/8hg8s/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM