24 lines
574 B
JavaScript
24 lines
574 B
JavaScript
export function fetchData(url, filters) {
|
|
return $.ajax({
|
|
url: url,
|
|
method: "POST",
|
|
data: filters,
|
|
})
|
|
.then((response) => {
|
|
if (!response) {
|
|
alert("No data found.");
|
|
return null;
|
|
}
|
|
try {
|
|
return JSON.parse(response);
|
|
} catch (e) {
|
|
alert("Invalid data format.");
|
|
return null;
|
|
}
|
|
})
|
|
.catch(() => {
|
|
alert("Error retrieving data.");
|
|
return null;
|
|
});
|
|
}
|