How to redirect through 'POST' method using Javascript?

前端 未结 11 1132
说谎
说谎 2020-12-05 10:05

I\'ve queried and doesn\'t work out what I\'ve found. Is there any way to redirect to give url with POST method using Javascript or jquery?

11条回答
  •  囚心锁ツ
    2020-12-05 10:29

    You can use serialize your form and all the data in post. Below is an example.

    $("#submit_btn").click(function(){
            $('.error_status').html();
                if($("form#frm_message_board").valid())
                {
                    $.ajax({
                          type: "POST",
                          url: "",
                          data: $('#frm_message_board').serialize(),
                          success: function(msg) {
                              var msg = $.parseJSON(msg);
                              if(msg.success=='yes')
                              {
                                                                                return true;
                             }
                             else
                             {
                                alert('Server error');
                                return false;
                            }
                           }
                    });
                }
                return false;
            });
    

提交回复
热议问题