sc_ajax_message("Message", "Title", "Parameters", "Parameters_Redir", "String_toast");

The sc_ajax_message() macro allows the display of customized messages during the execution of applications using Ajax events.

Through this macro, it is possible to present alerts, confirmations, or notifications using modal windows, toast-style notifications, and automatic redirection options.

Its use is exclusive to Ajax events.

Parameters

Parameter Required Accepts Empty Description and example
message Yes No

The message text to be displayed. May contain HTML.
Example:

  • "Operation completed successfully!"
  • "Error saving data"
title No Yes

The message window title. If not provided, it will be displayed without a title.
Example:

  • "Attention"
  • "Information"
configString No Yes

Defines the behavior and style of the message. It must be passed as a string with multiple options separated by &.
See details in Table 2: Configuration String

Example:

  • "toast=Y&timeout=3&type=success&toast_pos=top-end"
  • "modal=Y&button=Y&button_label=OK"
redirectParams No Yes

Defines the values that will be sent to the application specified in redir, in the format field1=value1;field2=value2.

Example:

"client_id=123;client_name=JOHN"


Even though not mandatory, the parameters must be passed in the correct order. If an intermediate parameter is omitted, it must be kept as an empty value.

 

Table 2: Configuration String

Property Description Values Example Restrictions / Notes
modal Defines if the message will be displayed in a modal.

Y - Message will open in a Modal

N - Message will display without a modal. This property can be omitted.

  • "modal=Y"
  • "modal=Y&width=50"

Only in applications with SweetAlert disabled.

timeout Defines how long the message is displayed in seconds. Only works with messages without a confirmation button. Accepts only numbers
  • "timeout=5"
  • "toast=Y&timeout=5"
  • "button=N&timeout=5"

Not compatible with confirmation button

  • In applications with SweetAlert disabled, requires button=N or omitted.
  • In applications with SweetAlert enabled, requires toast=Y or omitted.
button

Controls the display of the confirmation button inside the message. The behavior is to confirm the action and close the message.

Y - Confirmation button will be shown.

N - Message will show without a confirmation button. It will respect the timeout. Omitting the property has the same effect.

  • "button=Y"
  • "button=Y&button_label=Confirm"

Only in applications with SweetAlert disabled.

button_label Defines the label text shown on the button Button text
  • "button=Y&button_label=Close"
  • "button=Y&button_label=OK"

Requires confirmation button

  • Only in applications with SweetAlert disabled
  • Requires button=Y.
top

Sets the vertical position of the message using the top CSS property.

If omitted, position is calculated automatically.

Accepts only numbers
  • "top=650"
  • "top=650&timeout=5"

Only in applications with SweetAlert disabled and requires modal=N or omitted.

left

Sets the horizontal position of the message using the left CSS property.

If omitted, position is calculated automatically.

Accepts only numbers
  • "left=650"
  • "top=50&left=650&timeout=5"

Only in applications with SweetAlert disabled and requires modal=N or omitted.

width Sets the message box width in pixels Accepts only numbers
  • "width=650"
  • "width=650&timeout=5"

Only in applications with SweetAlert disabled

height Sets the message box height in pixels Accepts only numbers
  • "height=350"
  • "modal=Y&height=350&width=650"

Only in applications with SweetAlert disabled

redir

URL or application name for redirection. This attribute works only if the button property is enabled.

String with the application name or URL.
  • "redir=form_comparison"
  • "button=Y&redir=form_comparison"
  • "redir=https://scriptcase.com.br/&target=_blank"

Requires confirmation button:

  • Application with SweetAlert disabled requires button=Y or omitted.
  • Application with SweetAlert enabled requires toast=N or omitted.
redir_target Defines how the link specified in the redir parameter will be opened.

_blank - Opens in a new window or tab.

_self - Opens in the same frame it was clicked (default behavior).

_parent - Opens in the parent frame.

_top - Opens occupying the full window body (breaks all frames).

  • "redir=https://scriptcase.com.br/&target=_blank"
  • "redir=form_comparison&target=_parent"
Only if redir is defined.
show_close Displays a close button on the title bar. This property, when enabled, forces the title bar to be displayed even if the title parameter is empty.

Y - Close button is shown

N - Close button is not shown

"show_close=Y" Only in applications with SweetAlert disabled
body_icon Displays or hides the message icon. Even when this property is enabled, icon display depends on the application's Theme configuration.

Y - Message icon will be displayed.

N - Message icon will not be displayed.

"body_icon=N" Only in applications with SweetAlert disabled
toast Displays the message as a toast

Y - Uses toast notification

N - Uses SweetAlert message

"toast=Y" Only in applications with SweetAlert enabled
toast_pos Sets the toast position on the screen
  • top
  • top-start
  • top-end
  • center
  • center-start
  • center-end
  • bottom
  • bottom-start
  • bottom-end

"toast_pos=center&toast=Y&timeout=5"

"toast_pos=top&toast=N&type=warning"

Only in applications with SweetAlert enabled and requires toast=Y or omitted.
type Defines the icon to be displayed in the message
  • warning
  • error
  • success
  • info
  • question

"toast=Y&timeout=5&type=success"

"toast=N&type=warning"

Only in applications with SweetAlert enabled

 

Example

1. Message without SweetAlert using Modal

sc_ajax_message("Data saved successfully!", "Confirmation", "modal=Y&button=Y&button_label=OK&show_close=Y");

2. Message without SweetAlert

sc_ajax_message("Attention! Please fill in all fields.", "Warning", "button=Y");

3. Toast Message

sc_ajax_message("Product added to cart!", "", "toast=Y&type=success&toast_pos=top-end&timeout=3");

4. Message using SweetAlert

sc_ajax_message("Error processing request!", "Error", "type=error&button=Y");

To display the message using Toast, the "Use SweetAlert" option must be enabled in the application interface.