Chandu
Chandu

Reputation: 75

Page refresh with post request

In our application, we need to refresh the page. Now I am using the onclick() event to call the below javascript method.

function refresh() {
    document.getElementById('Question-Preview-ComboBox').style.display='none';
    document.getElementById('Question-Preview-RelatedSRTicketDetails').style.display='none';
    document.getElementById('Question-Preview-SignoffdetailControl').style.display='none';
    document.getElementById('Question-Preview-RelatedTicketDetails').style.display='none';
    document.getElementById('Question-Preview-PerformedBy').style.display='none';
    document.getElementById('Question-Preview-TextBox').style.display='none';
    document.getElementById('Question-Preview-CheckBoxMatrix').style.display='none';
    document.getElementById('Question-Preview-Radio').style.display='none';
    document.getElementById('Question-Preview-CheckBoxMatrixWOT').style.display='none';
    document.getElementById('Question-Preview-MultiLineText').style.display='none';

    if (windowDirty == true) {
        showModal('doyouwanttosave');
    }
    else {
        self.location = 'CreateQuestionnaireForm.html';
    }
}

The above script will ask users before they refresh the page "Do you want to save" and will make a GET request to call the controller method to reload the page. But our requirement is to change the GET request to POST for the above same functionality. Please suggest how can I change a GET request to POST?

Upvotes: 2

Views: 11412

Answers (3)

copy
copy

Reputation: 3372

You will need to create a hidden form, add it to the document and then submit it by calling the .submit() on the form's DOM object.

Upvotes: 6

Itay Kinnrot
Itay Kinnrot

Reputation: 721

you need to create a form and submit it - than you'll have post request.

Upvotes: 0

Sandeep G B
Sandeep G B

Reputation: 4015

Include the form tag and specify the action method as post

    <form action="destination_url" METHOD=Post>
     ....

   <input type=submit value="Submit" />
   </form>

Upvotes: 2

Related Questions