PHP Classes

File: fwphp/glomodul/z_examples/AJAX_form_valid/10projects/app.js

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/z_examples/AJAX_form_valid/10projects/app.js   Download  
File: fwphp/glomodul/z_examples/AJAX_form_valid/10projects/app.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/z_examples/AJAX_form_valid/10projects/app.js
Date: 1 year ago
Size: 971 bytes
 

Contents

Class file image Download
document.querySelector('#load').addEventListener('click', loadPosts); function loadPosts() { // Create the object const xhr = new XMLHttpRequest(); // Open the connection xhr.open('GET', 'https://jsonplaceholder.typicode.com/posts', true); // Execute the function xhr.onload = function() { if(this.status === 200) { const response = JSON.parse( this.responseText ); // print the contents let output = ''; var v_ii=0; response.forEach(function(post) { v_ii++ ; post.title = v_ii + '. ' + post.title ; output += ` <h3>${post.title}</h3> <p>${post.body}</p> `; }); document.querySelector('#result').innerHTML = output; } } // S e n d the r e q u e s t xhr.send(); }