html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <form action="/restest" method="post"> <input value="送信" type="submit"> <input style="display:none;" name="testname" value="testtesttest"> </form> </body> </html>
今までは上のようにユーザーにボタンを押してもらって
ポストしてもらっていたのですが、
html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <form action="/restest" method="post"> <input value="送信" type="submit"> <input style="display:none;" name="testname" value="testtesttest"> </form> <script> const correct=1; if(correct==1){ setTimeout(function(){ location="/restest"//ここでrestestにpostしたい },2500); } </script> </body> </html>
これから作るサービスでは上のように何らかの処理をした際、
自動的にサーバーにpostするといった内容にしたいのです。
このようなサービスをjavascriptだけで実装することは可能でしょうか。
またjavascriptで実装できるとしたら、どのように記述したらよろしいでしょうか。
初心者質問ではありますが、お答えしていただければ幸いです。
追記 :
この質問に誤解を招く様な内容があったので訂正します。
この質問はgoogleやteratail、Qiitaなどで3、40分ほど入念に調べて、
答えが出なかったため、質問しました。
ですのでできればこの質問に対する回答をご教授していただければ幸いです。
誤解を招く様に記述してしまいまして、大変申し訳ございませんでした。


まだ回答がついていません
会員登録して回答してみよう