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
chandra2ravichandra2ravi 

abort <apex:commandLink>

Hi,

 

I want to abort the Ajax request cause by clicking a commandLink.

 

<apex:commandLink action="{!status}" oncomplete="window.close();" />

 

how to stop async javascript. if i clcik status my popoup window close if request true or false. how to stop this.

 

thaks,

Ravi.

 

Imran MohammedImran Mohammed

Once the request is made, i dont think it can be stopped.

But you can always put a condition in the apex code, whether the code should execute or not on some condition.

From where are you getting the request value as true or false.

 

If you are getting the request value from apex controller, then you can have class variable defined that can be used in javascript.

 

Do you want the window to be closed only if request is true?

 

chandra2ravichandra2ravi

I placed below code but this is not working.

 

oncomplete="{!if(OwnerId=='','','javascript&colon;window.close();')}"

Imran MohammedImran Mohammed

Add this in the VF code

<script>

    function test()
    {
        if('{!ownerId}' != '')
            window.close();
    }
    
</script>

 

In VF tag just change the oncomplete to this

oncomplete="test();"