JSON and AJAX Tutorial: With Real Examples

LearnWebCode · 1.8M views · 2016 · 40:45

Open on YouTube

Web developmentPython, Ruby & scripting languagestutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as the tutorial they were following when they hit problems with XMLHttpRequest, JSON files and rendering fetched data, and as a starter for newcomers to JSON and AJAX.

Recommended by 2 people across 2 different months, 2016 to 2018.

What it is

A 40-minute beginner JavaScript tutorial from LearnWebCode (Brad Schiff) that explains what JSON and AJAX are. It builds a small page that loads animal data from external JSON files using XMLHttpRequest, with CodePen starter and finished demos.

What people said

Recommends JKhan · 2016-12 · Stack Overflow · on “How do I make a web blog that takes posts from seperate txt files?”

Use JSONs and AJAX to access the information that u want to display. JavaScriptObjectNotation or JSON is a way you can format your files and access information that you want. [ { "Title": "Title of post", "Date" : "1/1/1990", "Content": "h, i am blog" } ] The file is saved as a ".json" and its contents are organised as objects. This video is very helpful if you are new to JSON JSON and AJAX YouTube [this video]

Recommends Emonadeo · 2017-05 · Stack Overflow · on “how to load database entries in a css container”

As Pedro already said, I suggest you should first take a look at loading all of them at once before you have them on demand. I can't really tell how far you progressed in PHP yet so I will just start explianing from where you process the query and store it in $result . First of all you don't have to prepare the HTML before hand because that doesn't work for a dynamic amount of entries, so we want to avoid hard coding wherever possible. Instead we let PHP do that for us. if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { //This gets executed for every MySQL entry } } Inside the while loop we can use just echo the entries to the HTML. The content for that we can get from $row

Cites jimpix · 2017-01 · Stack Overflow · on “AJAX Request not logging to Google Developer Console”

I have a JavaScript file linked to my main HTML file. The JavaScript file contains an AJAX request which receives some JSON data from a URL and then is supposed to log it to the console. I checked the console multiple times, but I still don't see anything. I also made sure that Log XMLHttpRequests is ticked. I use Notepad++ and the latest version of Chrome. Here is my JavaScript var ourRequest = new XMLHttpRequest(); ourRequest.open('GET',' [LINK] '); ourRequest.onload = function(){ console.log(ourRequest.responseText); }; ourRequest.send(); I'm learning from here [this video] if you wondered.

Cites sifar · 2017-01 · Stack Overflow · on “XMLHttpRequest.onReadyStateChange not working in Chrome, Firefox, Internet Explorer”

I am using Aptana Studio 3 text editor and working on Windows 7 Enterprise OS. I have the following AJAX code which is not working on the local system to fetch JSON files kept on an https website. This example is taken from the Youtube video: JSON and AJAX Tutorial: With Real Examples [this video] index.html: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " [LINK] "> <html> <head> <meta name="test" content="content"/> <title>JSON and AJAX</title></head> <header> <h1>JSON and AJAX</h1> <link rel="stylesheet" href="styles.css" type="text/css" media="screen" title="no title" charset="utf-8"/> </header> <body> <script src="main.js"></script> <button type="button" onclick="function()" id="btn">Fetc

Cites Ciasto piekarz · 2017-01 · Stack Overflow · on “rendering HTML from javascript iteration to print table row not working with TypeError”

Learning from here [this video] . I am trying to render HTML of this sensor data: { "arduino": [{ "location": "outdoor", "temperatureInC": "18.30", "temperatureInF": "64.94", "humidity": "61" }, { "location": "drawingRoom", "temperatureInC": "25.10", "temperatureInF": "77.18", "humidity": "40.80" }] } and using this function to print HTML: function renderHTML(data) { var htmlString = "<table style='width:100%'><tr><th>Location</th><th>Temperature</th><th>Humidity</th></tr>"; for (i = 0; i < data.length; i++){ console.log(i); htmlString += "<tr><td>"+ data[i].location + "</td><td>" + data[i].temperatureInC + "&deg;C/ " + data[i].temperatureInF + "&deg;F </td> <td> " + data[i].humidity + "</td></tr

Cites user8473431 · 2017-09 · Stack Overflow · on “How to create your own JSON file locally?”

I was watching a YT video explaining JSON/AJAX ( link to video [this video] ) and in the video, the speaker uses a github.io website to link to their own JSON file ( link to file [LINK] ). Is it possible to create your own JSON file?

Cites Ryan Arellano · 2018-03 · Stack Overflow · on “Where to create JSON files on Visual studio 2017”

yes, I was trying out some JSON activities on this youtube channel ( [this video] ) and he was using an external JSON file and using a URL to call them. I would like to do the same but on the local machine using visual studio.

Cites Emanuel Gomez Arn · 2018-05 · Stack Overflow · on “Loading data with JSON.parse: Unexpected token /”

I'm pretty new with this JSON and AJAX staff, so I was following a tutorial on youtube: [this video] . The thing is that I have followed the steps exactly like in the video, but I get the following error: VM34:1 Uncaught SyntaxError: Unexpected token / in JSON at position 0 at JSON.parse (<anonymous>) at XMLHttpRequest.theRequest.onload (loader.js:5) My JSON script: [ { "name":"一", "sound": { "kunyomi": ["ひと.つ"], "onyomi": ["イチ"] }, "description":"Representaba la unidad, el absoluto. Cuando funciona como componente, este carácter adquiere el significado de suelo o de techo según su posición: si se encuentra encima de otro componente, toma el significado de techo; si está debajo, de suelo. Todas l