I'm using JS script to do an ajax call and get and display some data in a widget. I want to hide the widget when there are no results returned from the ajax endpoint. How do I do this in the JS script?
Tried using: $core_v2_widget.Hide()
But that results in the widget being hid all the time even when I have results returned.
#registerEndOfPageHtml()
<script type="text/javascript">
jQuery(function(j){
// do ajax call and get data
processRelatedTools(data);
function processRelatedTools(listOfTools) {
if(listOfTools.length > 0) {
// display data
}
else {
// hide widget
$core_v2_widget.Hide()
}
}
})
</script>
#end