Using Ajax

By default the plugin locks content of an initial element. But you can also load content using AJAX (Asynscroneous Javascript And XML).

For loading content using AJAX use the following Code:



$(".to-lock").sociallocker({

    theme: "flat",

    content: {

        // url to get ajax content
        url: "ajaxtest.html",

        // Notice:
        // the plugin will automatically take the response from the request and 
        // set it for you if you don't override the default success handler.

        // however, if you intend on using your own success callback, 
        // you'll need to set it yourself using the following way:
        success: function (api, data) {

            // finds content inside the response that we want to put
            var content = $("<div>").html(data).find("#content");

            // sets content for the locker
            api.element.html(content);
        }
    }
});

Related Posts

M.Muzammil

I am a web Designer & Graphics Designer. I love to program and design. Sharing knowledge is my passion & Programming is my Hobby. Want Help? Contact Me its free.!

Be The First To Comment

Add Comment