/** * [clickOnUrl Calls the service which increments the click to action statistic, by seeing data in json via an ajax request] * * @param {[type]} anchor [description] * * @return {[type]} [description] */ function clickOnUrl(anchor){ let name; let label = anchor.getElementsByClassName('label-clicktoaction')[0].innerHTML; // Raw text recovery (without html char) if (anchor.getElementsByClassName('name-clicktoaction').length > 0){ name = anchor.getElementsByClassName('name-clicktoaction')[0].innerHTML; }else{ name = label; } var data = { "content":{ "href": anchor.href, "name": name, "label": label, "ref_user": "", "ref_question": "", "login": "", "space": "" } }; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { return true; } }; xhttp.responseType = 'json'; xhttp.open("POST", "https://teambrain.app/centralBrain/front/page/statButton/statButton.php", true); xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); xhttp.send( JSON.stringify(data) ); }