Com And Hosting

You can access the session value of any page item in APEX quite easily using jQuery. Session value can be retrieved using &PX_ITEM_NAME. tag even in html code. APEX replace this tag with the item session value. Cool yeah. Recently I have used this for an API call using jQuery. Here is an example –

$(function(){

//get the session value for the page item
var web_flag = '&P210_WEB_FLAG_H.';
var web_flag_old = $('#P210_WEB_FLAG option:selected').val();
var sit_id = '&P210_SIT_ID.';
var title = '&P210_NAME.';
var name = '&APP_USER.';

if (web_flag != web_flag_old) {
    if (web_flag == 'N') {

        $.ajax({
            type: "POST",
            cache: false,
            url: "http://api.your-site.com/integrator",
            beforeSend: function (xhr) {
                xhr.setRequestHeader('AUTHORIZATION', 'Basic YWRtae32ZGVjLXB2czI=');
            },
            data: {
                token: "crtrekYPbvw75TrAPm3U",
                type: "site",
                id: sit_id,
                name: name,
                title: title,
                action: "disable"
            },
            error: function (er) {
                alert("Sorry cannot disable the site in remote CMS");
            },
            success: function (s) {

                alert('This site has been disabled in remote CMS.');
            }
        });
    }
}

});

You need to have clear understanding about jQuery to use this example as I have not explained in details about jQuery library. You can read more about jQuery in their website.

 

Leave a Reply

Your email address will not be published.