Cascading drop-down in SharePoint OOTB list forms

In one of my recent project in SharePoint Online (Office 365), there was a requirement to implement cascading of drop-down. In my case, the two drop-downs are of Lookup Type getting values from a Master list. The two drop-downs were:-

Drop-down 1 – Event Type
Drop-down 2 – Event Category






The code used to implement the above functionality is:-

var userEntry = [];
var results = data.d.results;
$.each(results, function(index,dataRec) {
});//End of push
//alert(“In each userEntry”+ JSON.stringify(userEntry));
});//End of each
for(var j=0;j<userEntry.length;j++){
$(‘select[title=”Events Category Required Field”]’).append($(‘<option>’, { value: userEntry[j].id,text : userEntry[j].name}));
}//End of for