mercredi 16 janvier 2019

How to get JSON file from server? (ASP.NET)

I have a simple web application that operates with a set of words using JS. In order to test the main code I just put a heeded data in a variable in my script.

CONST WORDS = [
    ["Computer", "Ordinateur", "https://www.lifewire.com/thmb/nNDKywb8qvKzhxelVAR95sEHBj0=/768x0/filters:no_upscale():max_bytes(150000):strip_icc()/Acer-aspire-x3300-5804ec185f9b5805c2b6b9e6.jpg"],
    ["Function", "Fonction", "http://latex-cookbook.net/media/cookbook/examples/PNG/function-plot.png"],
    ["Server", "Serveur", "https://effortz.com/wp-content/uploads/dedicated-hosting-server.png"]
]

Now I need to build a database (already done) and get such data from the server. So, the question is how do I acquire JSON file from the server using JS? I know how to make GET requests, but what should I do on the server to make it response? (or may be there is an easier way to get this data in JS, considering that I already got it from DB and can easy display on the webpage). Here is a backend code

namespace LFrench
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<Words> WordsSet = Words.GetWords("Business");//recieving from DB a set of words, that i need to use in JS
        }
    }
}




Aucun commentaire:

Enregistrer un commentaire