Ajax call to servlet in sightly
Hi All,
I am struggling for the past two days with the issue mentioned below :
1] I have a component.html and I have the below section[to call js]
<script>
$(window).load(function() {
getData();
});
</script>
2] I have component.js file with the below section
function getData() {
$.ajax({
type: 'GET',
url:'/bin/customservlet',
success: function(msg){
var json = jQuery.parseJSON(msg);
var msgId= json.id;
var lastName = json.lastname;
var firstName = json.firstname;
$('#ClaimNum').val(msgId);
$('#json').val("Filed by " + firstName + " " + lastName);
}
});
}
Issues I am facing
a] When I write the ajax call in component.html it works fine, but if I have that in a seperate js and call, the servlet is not getting invoked.
b] Once the above is done, I have to send a property via the above Ajax call to servlet. That property is available to me in component.html file in the form of ${xyz.selectors}[the property was retrieved via Java use class]
Just an FYI : The AJax call is not completely written yet.
I am struggling here for quite some time. Any thoughts/pointers on this will be really helpful.