#104 jquery convert to jaascript

master
Agriya Dev5 2021-05-24 19:46:43 +05:30
parent 37cca80026
commit 5830fed793
1 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,3 @@
/* globals $ */
const atags = document.querySelectorAll('a');
Array.prototype.forEach.call(atags, function (aEle) {
aEle.addEventListener('click', function (event) {
@ -41,10 +40,22 @@ Array.prototype.forEach.call(atags, function (aEle) {
});
img.src = href;
} else {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
let data = xhr.responseText;
post({ href, data });
return data;
} else {
return false;
}
};
xhr.open('GET', href, false);
xhr.send(null);
// Do ajax request for image's href value
$.get(href, function (data) {
/* $.get(href, function (data) {
post({ href, data });
}, 'html'); // 'html' is necessary to keep returned data as a string
}, 'html'); */ // 'html' is necessary to keep returned data as a string
}
return false;
});