Koooomo Koooomo - 3 years ago 145
Ajax Question

How and where to save data I receive from an ajax call?

I'm doing an ajax request and I want to save data I receive from it on a page as oppossed to saving it in a variable. How can I do that?

Answer Source

If you want to keep the data in memory, you can use browser's local storage :


With local storage, web applications can store data locally within the user's browser.

// Store
localStorage.setItem("lastname", "Smith");

// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("lastname");
Try it Yourself ยป

If you want to display the data on the page, you can use javascript to update the page e.g.

document.getElementById("result").innerHTML = ajaxResult;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download