console.log("Start");
var request = new XMLHttpRequest();
request.open('GET', 'http://localhost/avtokolya/market/l_json.php');
request.onreadystatechange = function(e) {
if (this.readyState == 4) {
if (this.status == 200) {
var response = JSON.parse(this.responseText);
var str = response['1'];
//alert(str.images);
if ('http://slando.ua/post-new-ad/'==window.location.href){
console.log("slando");
window.onload = function(){
//document.getElementById("category-breadcrumb-container").addEventListener( 'click');
var element = document.evaluate( '//*[@id="category-breadcrumb-container"]/dl/dt/a',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
element.click();
// первый аргумент - функция
function second_passed() {
document.getElementById('cat-3').click();
var element = document.evaluate( '//*[@id="category-3"]/div[2]/div[2]/div/ul/li[7]/a',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
element.click();
var element = document.evaluate( '//*[@id="category-111"]/div[2]/div[2]/div/ul/li[1]/a',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
element.click();
var element = document.evaluate( '//*[@id="targetid_private_business"]/dd/ul/li[3]/a',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
element.click();
}
setTimeout(second_passed, 2000)
//slando
document.getElementById('add-title').value=str.product_name;
document.getElementById('add-description').value=str.product_desc;
}
}
}
else {alert("Сетевая ошибка...");
}
}
}
request.send(null);
console.log("end");