Can I post JSON without using AJAX?

后端 未结 5 776
不思量自难忘°
不思量自难忘° 2021-01-12 15:35

I have some data, lets say:

var dat = JSON.stringify(frm.serializeArray())

I want to submit this to the server using a roundtrip (aka, non

5条回答
  •  情话喂你
    2021-01-12 16:03

    1. Create an HTML form with unique "id" attribute. You can hide it using CSS "display:none". Also fill the action and method attributes.
    2. Add a text or hidden input field to the form. make sure you give it a meaningful "name" attribute. That's the name that the server would get the data within.
    3. Using JQuery (or plain old javascript) copy the variable "dat" into the input field
    4. Submit the form using script

提交回复
热议问题