Javascript Fetch Examples

Javascript fetch, load image, json and database

basic call no option returned as json

Ajax Fetch loading image example useing a Simple listing

Ajax Fetch Tree list

Ajax Fetch local text

Example of load the text from text file display code used to load text

Ajax Fetch error reporting

Example of load the text from text file display code used to load text

Pass params to php, using php POST

 
FormData 
The FormData object lets you compile a set
    of key/value pairs to send.
It is primarily intended for use in sending form data, 
but can be used independently from forms in 
order to transmit keyed data.
Creating a FormData object from scratch
    var formData = new FormData();
    formData.append('status', 'Open');	
	formData.append('type', 'Read');
	formData.append('file', 'read.txt');
then
  fetch(url, { method: 'POST', body: formData }) ...

Add data to an existing form
var formElement = document.querySelector("form");
....
PHP side just use $POST as normal
Understand formdata

Example 3rd party JSON data

Ajax Fetch get data from MYSQL

Reads a record from mysql database