How to make an ajax call in sightly component ???
Steps:
Follow the below steps to make an ajax call to a servlet in sightly.
1.Create a sightly component(Lets say it is component.html)
2.Create a file with name js.html under the component.
3.Write the required ajax method to invoke the servlet.
4.Include js.html in component.html
Code:
Component.html:
Here is the ajax html file included
<div data-sly-include="js.html"></div>
Js.html:
<script>
function invokeajaxCall() {
$.ajax({
type: 'GET',
url:'/libs/migration',
success: function(msg){
alert('Method Success');
}
});
}
$(window).load(function() {
invokeajaxCall();
});
</script>
Component Structure:
How to i send some parameters like dialog properties from sightly to this AJAX call.?
ReplyDeleteWhere exactly you are invoking call.Please tell me more on this.
DeleteAm using server-side JavaScript USE API to read the dialog properties like below
ReplyDeleteuse(function () {
var myproperty = properties.get("renderpagetype");
return { callajaxvariable: myproperty,
};
});
and i need the "callajaxvariable" value to to call AJAX request. How to do it.?