Я не могу передать событие, переданное в func, встроенной функции, вызываемой для XMLHttpRequest.onreadystatechange
. При передаче события из функции func
во встроенную функцию оно сообщает неопределенное значение. PFB встроенные комментарии для того же.
event.currentTarget.addEventListener("click", func, false);
function func(event){
var data1;
var str=event.currentTarget.textContent; //here variable value for str is coming successfully.
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(event)
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert("event is"+event.currentTarget.textContent); //here event.currentTarget.textContent is coming undefined . Is there a way to get the value here similar to variable str?
data1= xmlhttp.responseText;
}
}
xmlhttp.open("GET","Jr6?q="+str,true); //here simply calling the servlet to get the data which is stored in data1 above.
xmlhttp.send();
}