store pics from api in db
This commit is contained in:
@ -14,6 +14,21 @@ class Req {
|
||||
xhttp.send(data);
|
||||
}
|
||||
|
||||
static postData(url, data, callback) {
|
||||
const xhttp = new XMLHttpRequest();
|
||||
xhttp.open("POST",url,true);
|
||||
xhttp.onload = function(){
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
callback(xhttp.responseText);
|
||||
}
|
||||
}
|
||||
xhttp.onerror = function () {
|
||||
console.log("error")
|
||||
};
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
xhttp.send(data);
|
||||
}
|
||||
|
||||
static get(url, callback) {
|
||||
const xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function(){
|
||||
|
36
js/index.js
36
js/index.js
@ -1,22 +1,22 @@
|
||||
Req.ready(() => {
|
||||
Req.post("php/index.php", "action=getMovies&test=2", function (dta) {
|
||||
console.log(dta);
|
||||
for (const ii in dta.data) {
|
||||
document.getElementsByClassName("mediawrapper").item(0).insertAdjacentHTML('beforeend', `
|
||||
<div class="mediatile">${dta.data[ii].url}</div>`); // <video controls src="${dta.data[ii].url}"></video>
|
||||
}
|
||||
// Req.post("php/index.php", "action=getMovies&test=2", function (dta) {
|
||||
// console.log(dta);
|
||||
// for (const ii in dta.data) {
|
||||
// document.getElementsByClassName("mediawrapper").item(0).insertAdjacentHTML('beforeend', `
|
||||
// <div class="mediatile">${dta.data[ii].url}</div>`); // <video controls src="${dta.data[ii].url}"></video>
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// Req.post("php/index.php", "action=storePic", function (dta) {
|
||||
// console.log(dta);
|
||||
// });
|
||||
|
||||
console.log("startup")
|
||||
Req.postData("php/index.php", "action=readPic", function (dta) {
|
||||
document.getElementById("tempici").src = dta;
|
||||
});
|
||||
|
||||
Req.post("php/index.php", "action=storePic", function (dta) {
|
||||
console.log(dta);
|
||||
});
|
||||
|
||||
Req.post("php/index.php", "action=readPic", function (dta) {
|
||||
console.log(dta);
|
||||
document.getElementById("tempici").src = dta.data;
|
||||
});
|
||||
|
||||
Req.post("php/index.php", "action=getDbSize", function (dta) {
|
||||
console.log(dta);
|
||||
});
|
||||
// Req.post("php/index.php", "action=getDbSize", function (dta) {
|
||||
// console.log(dta);
|
||||
// });
|
||||
});
|
Reference in New Issue
Block a user