• NHA
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi everyone,

 

I have an inline VFPage in which I detect page closing or page refresh or whenever the user leaves the page using the <body onunload="jsFunction()">. When it happens, I call some Apex code using Javascript remote action.

 

It works perfectly in the "standard" view of a page. But when I am using the console, I can't launch the Apex remote code.

 

I made some investigation on that. Apparently, the js code is running because I can console.log() some variables, but the call of MyExtension.myMethod doesn't work.

 

The js code :

 

var var1 = 'value1';
var var2 = 'value2';

console.log(var1);
console.log(var2); MyExtension.myMethod(var1, var2, function(result, event) { if(event.status) { console.log("Update successful"); } else { console.log("Update unsuccessful"); } }, {escape:true});

cosole.log('test');

 

The Apex code :

global with sharing class MyExtension {
	@RemoteAction
	global static void myMethod(String var1, String var2) {
		// my logic
	}
}

 

Even the console.log('test') works, but the console.log('Update successful') or console.log(Update unsuccessful') does not appear... Plus, I don't get any Debug log about that remoting.

 

There is no need to see my logic because like I said it works perfectly in standard.

 

Is there any other ways to detect cosole tab or subtab closing and call some Apex logic ?

 

Thank you !