I have created a popup window against a command button in visualforce page. Now I want to perform an action for the same button in controller and showing the output in that popup. Now the problem is When I click on the button, the popup appears and vanishes after some time as the action function is executing in controller. Please help me. How can I fix the popup on the page. Please help me.

Here is my vf page:

<div class="col-xs-9 nopadding  pull-left text-left addAttachment hideOnClose" id="addBtnDiv1" style=' margin-top: 0px;  background-position: left 0px;'>
<input class="btn Frutiger55-13px btn-primary btn-cos" id="addBtnConfiden" type="button" value="Add Confidential Files(FTP)" style="margin-left: 32px;" action="{!getResponse}"/>

<apex:form >
    <div id="ConfidentialFile" class="pop_container">
        <apex:outputText value="{!response}"/>

            function(e) {

function openAddConfidentialFile(){
    fileList = '';
    document.querySelector('#dropzone').value = '';
    $('#agreeCheck').prop('checked', false);
    attachmentList = [];
    $('#agreeError').css('display', 'none');
        autoOpen: false,
        modal: true,
        position: 'center',
        resizable: false,
        draggable: false,
        scrollable: true,
        cache: false,
        closeOnEscape: true,
        open: function(event, ui) {
            $('.ui-widget-overlay').bind('click', function() {

    return false;

My controller is:

public class COSCaseDetailController_Clone {
public HTTPResponse res{get; set;}
    public String resBody{get; set;}
    public String endpoint{get; set;}

    public String response{get; set;}
    public string pass{get; set;}

 public void getResponse()
         /*-----Rest API call--------*/
        HttpRequest req = new HttpRequest();
        req.setMethod('GET');                                    //Seting HttpRequest Method
        req.setHeader('Accept', 'application/json');
        Http http = new Http();
        HTTPResponse res = http.send(req);                 // Executing web service call
        System.debug('STATUS:' + res.getStatus());
        System.debug('STATUS_CODE:' + res.getStatusCode());
       // blob retFile = res.getBodyAsBlob();

        response = res.getBody();


Instead of doing your way, You can do following way.

Write action function to call a controller method getResponse, when you click button instead of calling java function, call action function. it will execute first you controller method, Once execution is over, it is going call openAddConfidentialFile java-script function on complete of action function. No need explicit you have call those function. simply action function do for you.Your show model java-script function will call.

 // your code 
 <apex:actionFunction name="actionFunction" action="{!getResponse}" rerender="renderID" status="myStatus" oncomplete="openAddConfidentialFile();"/>
 <apex:actionStatus startText="Loading..."  stopText="" id="myStatus"/>

 // your code 

 <input class="btn Frutiger55-13px btn-primary btn-cos" id="addBtnConfiden" type="button" value="Add Confidential Files(FTP)" style="margin-left: 32px;" onClick="actionFunction();"/>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.