# Performing Callbacks after Form Submits (For Dev)

Occasionally, you will want custom landing page behavior to be triggered after checkout or after an upsell, but before the next page attempts to load.

This can be accomplished by assigning a callback function to a global JavaScript variable named: 'kform\_formSubmitCallback'. The signature of this callback is: 'function(response, success)', where response is the API response or error message, and success is either true for a successful transaction or false otherwise.

For example, placing the following code on your upsell page will automatically redirect the customer to the next page, even if the transaction declined, once they close the error dialog:

```
window.addEventListener('load',function()
{
    kform_formSubmitCallback = function(response, success)
    {
        if (!success)
            document.location.href = <?php echo $ksdk->redirectsTo; ?>;
    }
}
```

Additionally, you can prevent the page from automatically redirecting to the next page after a successful transaction by returning false from this callback:

```
kform_formSubmitCallback = function(response, success)
{
    return !success;
}
```

Returning anything other than false results in the Konnektive SDK continuing with normal behavior after the callback.

(i.e. Automatically redirecting on transaction success, and doing nothing after a transaction decline or error.)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.konnektive.com/konnektive-crm/crm-setup/campaign-setup/landing-page-setup-form-code/performing-callbacks-after-form-submits-for-dev.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
