How we can call ajax with url in erpnext(frappe)?

I am using jquery easyui for create tree but I am unable call url .
$(‘#tt’).tree({
url: ‘/api/method/sapcon_erpnext.api.bom_tree_all’,
loadFilter: function(rows){
debugger
return convert(rows);
}
});
I am getting error : POST /api/method/my_erpnext.api.bom_tree_all HTTP/1.1" 400

Maybe you can try something like:

frappe.ui.form.on(“DocType”, {
refresh: function(frm) {
$.ajax({
url: “Enter URL here”,
type: ‘POST’,
dataType: ‘json’,
success: function (data, textStatus, xhr) {
console.log(data)
msgprint((“Success!!”));
},
error: function (data, textStatus, xhr) {
msgprint(
(“Failure!!”));
}
});
}
});