+ Start a Discussion
bpl3792bpl3792 

Need to use controller + jsremoting for page redirect

I'm trying to pump a string into a visualforce page that creates a CSV. The problem I'm having is when I return the page reference to the JS Remoting event, no redirect actually happens...The console just shows the page I want to redirect to.
Here's my code from the controller...

    @RemoteAction
    global static PageReference HTMLDump(string html) {
        //getCSV(html);
        CSVContent=html;
        PageReference pageRef=page.CSV_ExportPage;
        pageRef.setRedirect(true);
        system.debug(CSVContent);
        return pageRef;
    }

 

            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.CSV_ExportPage.HTMLDump}',
                   CSVRows,
                   function(result, event)
                   { 
                            console.log(result);     
                   });

 After doing a system.debug in the controller I was able to verify that the string is being passed in fine...it's just the redirect that isn't working. I have a feeling it has something to do with the way I'm using the JS remoting but I'm not sure how else to go about it.


 

Any help in the right direction would be greatly appreciated!