Just a thought, nice code snippet, but is a server-side code required? What if this API call was used:
frappe.call({
method:"frappe.client.get_list",
args:{
doctype:"Item Attribute Value",
filters: [
["supplier","=", frm.doc.supplier]
],
fields: ["parent"],
parent: "Supplier"
},
callback: function (response) {
/* see above */
}
});