You just need to call the SmartMenus initialization code after you have inserted the menu structure in the DOM. Here is a very basic example that gets the menu structure from an external file, prepends it in the body and then the menu is initialized:
$.get('URL_to_menu_structure_file', function(htmlStr) {
// insert menu structure
$('body').prepend(htmlStr);
// SmartMenus initialization code
$('#main-menu').smartmenus({
subMenusSubOffsetX: 1,
subMenusSubOffsetY: -8
});
});