Using Ajax
M.Muzammil
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:
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);
}
}
});
Be The First To Comment