pastioke.com
Javascipt

Javascript Post Form

a
<script>
/**  * sends a request to the specified url from a form. this will change the window location.  * @param {string} path the path to send the post request to  * @param {object} params the paramiters to add to the url  * @param {string} [method=post] the method to use on the form  */
function f_post(path, params, method='post') {

// The rest of this code assumes you are not using a library. // It can be made less wordy if you use one. const form = document.createElement('form')
form.method = method
form.action = path

for (const key in params) {
  if (params.hasOwnProperty(key)) {
    const hiddenField = document.createElement('input')
    hiddenField.type = 'hidden'     hiddenField.name = key     hiddenField.value = params[key]
    form.appendChild(hiddenField)   } }
document.body.appendChild(form) form.submit() } </script>
a

🚀 Butuh solusi instan siap pakai?

Dapatkan modul & script server production-ready langsung di web store kami.

Kunjungi Toko Digital →

Komentar

Belum ada komentar. Jadilah yang pertama memberikan komentar!

Kirim Komentar