You need to sign in to do that
Don't have an account?
Eyal Hutter 1
remote action is invoked but not returned to handler function
Hey,
I have a visualforce component that is calling the remote action "insertAllRecords" in the controller by clicking a button and as I seen there is a strange behaviour:
Sometimes when I click the button the remote action is doing all the function code and returning to the handler but sometime it is just doing the code without returning to the handler. I saw on the debug log that all the code worked successfully without errors, also checked the chrome browser console and ther are no errors there. I have a jquery.noconflict() call and I tried to isolate the call to the remote action from the rest of the visualforce page and the behaviour hasn't changed.
at the handler there should be redirecting to a different page but that is not happening all the time and the console.log too that I have.
It looks like a conflict or a bug in salesforce but it is not showing any error.
Here is the code of the javascript:
function ajaxPost(listToInsert) {
var campaignId = '{!campaignId}';
var objectType = '{!typeObject}';
var allIdsString = listToInsert;
allIdsString = allIdsString.substring(1, allIdsString.length-1);
var allIdsArray = allIdsString.split(",");
console.log('campaignId: ' + campaignId);
console.log('allIds: ' + allIdsArray);
console.log('objectType: ' + objectType);
vfTableGenerate.insertAllRecords(campaignId, allIdsArray, objectType,
function(result, event){
console.log('111');
console.log(event.status);
if (event.status) {
top.window.location = result;
}
});
}
the visualforce button:
<apex:commandButton value="Add To Campaign Members" onclick="ajaxPost('{!recordToInsertList}');"/>
Any help will be great!
I have a visualforce component that is calling the remote action "insertAllRecords" in the controller by clicking a button and as I seen there is a strange behaviour:
Sometimes when I click the button the remote action is doing all the function code and returning to the handler but sometime it is just doing the code without returning to the handler. I saw on the debug log that all the code worked successfully without errors, also checked the chrome browser console and ther are no errors there. I have a jquery.noconflict() call and I tried to isolate the call to the remote action from the rest of the visualforce page and the behaviour hasn't changed.
at the handler there should be redirecting to a different page but that is not happening all the time and the console.log too that I have.
It looks like a conflict or a bug in salesforce but it is not showing any error.
Here is the code of the javascript:
function ajaxPost(listToInsert) {
var campaignId = '{!campaignId}';
var objectType = '{!typeObject}';
var allIdsString = listToInsert;
allIdsString = allIdsString.substring(1, allIdsString.length-1);
var allIdsArray = allIdsString.split(",");
console.log('campaignId: ' + campaignId);
console.log('allIds: ' + allIdsArray);
console.log('objectType: ' + objectType);
vfTableGenerate.insertAllRecords(campaignId, allIdsArray, objectType,
function(result, event){
console.log('111');
console.log(event.status);
if (event.status) {
top.window.location = result;
}
});
}
the visualforce button:
<apex:commandButton value="Add To Campaign Members" onclick="ajaxPost('{!recordToInsertList}');"/>
Any help will be great!
The funny thing is that the handler is not called only if you call the remote action in the first time. In the second time and so on it works!
Can someone please help to find a solution?
More info: I'm using the remote action in a apex component with a jquery data table.