Created
May 5, 2021 18:35
-
-
Save Orbis25/21c689f0d11fb9e272098c3a698c7233 to your computer and use it in GitHub Desktop.
Load partials view generics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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