I wrote a small basket script, output the purchased goods on the basket page, output the goods as follows: I send ajax request to the product page and try to pull id = "productName" from there. the basket script looks like this:
for (var i = 0; i < localStorage.length; i++) { var limkForProductPage = '/e-store/' + localStorage.key(i);//ссылка на страницу товара $( "#rezult" ).load( "limkForProductPage #productName" ); } But the problem is that jquery doesn’t understand that limkForProductPage is a variable and tries to go to mysite.com/limkForProductPage I tried on native js but I don’t understand how I can take an element like
var xhr = new XMLHttpRequest(); xhr.open('GET', p, false); xhr.send(); if (xhr.status != 200) { alert( xhr.status + ': ' + xhr.statusText ); } else { // вывести результат var xmlDoc = xhr.responseText; } how do i get id = "productName"? tried so
var xmlDoc = xhr.responseText.getElementById('productName'); but gives an error
getElementByIdmethod - Grundy