function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GV1GV1 

'oncomplete' not working for my 'actionfunction', please help

Below is my code: the oncomplete function of my actionfunction is not throwing allert.

Can someone help? 

 

<div>

<apex:inputCheckbox id="abc1" value="{!ss.IsCompleted}" onclick="javascript&colon;updateLobStg('{!ss.LobStageId}', this,'{!ss.Description}');"/>

</div>

 

 

<script>

function updateLobStg(lobStgId,checkBox,description){
var isChecked = $(checkBox).is(':checked');
/*------ some code----*/
af_updateLobStage(lobStgId,isChecked);

</script>

 

 

 

<form>

<apex:actionfunction  name="af_updateLobStage" status="counterStatus" action="{!updateLobStage}" oncomplete="window.alert('clicked')">
<apex:param name="lobStgId" value="" assignto="{!selectedLobStageId}"/>
<apex:param name="isChecked" value="" assignto="{!isLobStageCompleted}"/>
</apex:actionfunction>

</form>

 

 

There is no error on the controller side and its executing fine.

souvik9086souvik9086

It should work. oncomplete code is correct. It is working in one of my actionfunction. I think there may be some error in the Javascript, resulting in not showing that alert.

 

You can check that in

Tools -> WebDevelper -> Error Console

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

Marko LamotMarko Lamot

problem might be in '{!ss.Description}'

 

if ss.Description contains multiline or other "non-valid" chars, it corrupts your java script...

 

you should use JSENCODE for textfields

 

'{!JSENCODE(ss.Description)}'

 

 

GV1GV1

The values which i am passing in the actionfunction  to the controller is getting processed and  is updating the records perfectly as expected.

Its just that I am not able to get anything done on 'oncomplete'

sfdcfoxsfdcfox
This is not an AJAX request, so it won't call the JavaScript. Add a "rerender" attribute to the actionFunction (it can be blank, such as reRender="").