使用javascript发布表单(非Ajax)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用javascript发布表单(非Ajax)相关的知识,希望对你有一定的参考价值。
This javascript function takes the URL of the target page and an associative array of name/values paires and POSTs the data to the supplied URL by dynamically creating a form and then submitting it.
// POST Function function postwith (to,p) { var myForm = document.createElement("form"); myForm.method="post" ; myForm.action = to ; for (var k in p) { var myInput = document.createElement("input") ; myInput.setAttribute("name", k) ; myInput.setAttribute("value", p[k]); myForm.appendChild(myInput) ; } document.body.appendChild(myForm) ; myForm.submit() ; document.body.removeChild(myForm) ; } // Fire function postwith( 'post.aspx', { user:'peter' , cc:'aus' });
以上是关于使用javascript发布表单(非Ajax)的主要内容,如果未能解决你的问题,请参考以下文章