admin管理员组

文章数量:1289986

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?

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?

Share Improve this question edited Dec 5, 2011 at 12:22 Crab Bucket 6,2779 gold badges41 silver badges73 bronze badges asked Dec 5, 2011 at 12:15 ChanduChandu 751 gold badge3 silver badges11 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 6

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.

Include the form tag and specify the action method as post

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

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

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

本文标签: javascriptPage refresh with post requestStack Overflow