Skip to content

Instantly share code, notes, and snippets.

@Orbis25
Created May 5, 2021 18:35
Show Gist options
  • Save Orbis25/21c689f0d11fb9e272098c3a698c7233 to your computer and use it in GitHub Desktop.
Save Orbis25/21c689f0d11fb9e272098c3a698c7233 to your computer and use it in GitHub Desktop.
Load partials view generics
var LoadPartialView = async (contentId, url) => {
const content = $(`#${contentId}`);
content.empty();
content.append("cargando...");
try {
const result = await fetch(url, { method: "GET" });
content.empty();
if (result.status === 200) {
content.append(await result.text());
} else if (result.status === 400) {
content.append(`<p>${await result.text()}</p>`);
}
} catch (e) {
content.empty();
content.append(`Error al cargar la información, intente de nuevo mas tarde`);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment