JavaScript:
function executeOnclick() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
myFunction(xhttp);
}
};
xhttp.open("GET","http://try.com/students/search.php?stud_id=?" +x , true);
xhttp.send();
}
function myFunction(obj){
var xmlDoc = obj.responseText;
var x = xmlDoc.getElementsByTagName("id");
document.getElementById("demo").innerHTML = xhttp.responseText;
}
HTML:
<img id="1210" onclick="executeOnclick()" onload="myElement(this);"
class="Cpictures" src="1.jpg" width=50px height=75px alt="Robert" />
This code doesn't work. I want that when I call the myFunction function, I get the Id of the image and pass it to my API. How do I do that?