Home >Web Front-end >JS Tutorial >How to submit a request using JS using POST method (detailed answer combined with code)
The following is the method I compiled for you to use JS to submit requests using POST method. Interested students can take a look.
Usually write hidden form tags, use 2d078126420737c6f9206fa14d9b1802To call the js function and then submit
You can also write it all in js. The following is an example I saw written by others in a question and answer channel. I put it here
function post(URL, PARAMS) { var temp = document.createElement("form"); temp.action = URL; temp.method = "post"; temp.style.display = "none"; for (var x in PARAMS) { var opt = document.createElement("textarea"); opt.name = x; opt.value = PARAMS[x]; // alert(opt.name) temp.appendChild(opt); } document.body.appendChild(temp); temp.submit(); return temp; } //调用方法 如 post('pages/statisticsJsp/excel.action', {html :prnhtml,cm1:'sdsddsd',cm2:'haha'});
The above is what I compiled I will give you a method of using JS to submit requests using POST method. I hope it will be helpful to you in the future.
Related articles:
How to implement printing in JS (detailed answer combined with code)
About in js Simple operation for downloading files (code attached, detailed answer)
# Questions about adding ! in front of function in js, the code is attached
The above is the detailed content of How to submit a request using JS using POST method (detailed answer combined with code). For more information, please follow other related articles on the PHP Chinese website!