I am currently attempting to implement a callback function for this particular JavaScript function.
function Filtering_GetSite(siteElement) {
$.ajax({
type: "POST",
url: "samle.asmx/f1",
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var filtersitedetails = response.d;
var appendItem = "";
$(siteElement).empty();
$.each(filtersitedetails, function (index, Filtering_GetSiteInfo) {
var activeappend = "";
var id = Filtering_GetSiteInfo.id;
var site = Filtering_GetSiteInfo.site;
activeappend = "<option value=" + id + ">" + site + "</option>";
appendItem += activeappend;
});
$(siteElement).prepend('<option disabled="disabled" selected="selected" value="">Select Site</option>');
$(siteElement).append(appendItem);
},
error: function (response) {
alert("error in Filtering_GetSite");
}
});
}
This is the method I am using to call the function and trying to incorporate a callback:
Filtering_GetSite("#txt-site-name", function () {
alert('ok')
Dashboard_GetAgentInfo(agentParam,agentElement);
});
However, I am facing an issue where the alert does not trigger upon completion of the function. How can I resolve this?