Answer the question
In order to leave comments, you need to log in
JSON, AJAX, XHR?
Good day!
I'm just starting to learn JS, so I have a question. I've been googling and reading articles for 4 hours now and can't reach me in any way.
So I wanted to deal with AJAX. And met with misunderstanding. On learn.javascript.ru they talk about XMLHttpRequest, but there is also $.ajax.
For example, I have the address of the page on which the format data is located:
{"nouns":["a","b","c"],"adjectives":["e","f","g","h"]}
var req = new XMLHttpRequest();
req.open('GET', 'https://my.site./dictionary', true);
req.send();
req.onload = function() {
alert( this.responseText );
}
$.getJSON( "https://my.site/dictionary", function( data ) {
var nouns = data.nouns;
var adjectives = data.adjectives;
});
Answer the question
In order to leave comments, you need to log in
Read up to:
On learn.javascript.ru they talk about XMLHttpRequest, but there is also $.ajax.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question