If you don't have src for the image and you have not defined any width or height to the image, then the image will not be displayed at all. Its size will be 0px in the browser window. Then how can you say that you clicked on this image? In such cases, you are actually clicking on the parent element and not the image.
Give width and heigh to the image and the click event will work. Here is a working example:
<html>
<head>
<script type="text/javascript">
function changedata()
{
alert('hello');
}
</script>
</head>
<body>
<div id="imgdiv2">
<img src="" alt="" onclick="changedata();" style="width:100px;height:100px;" />
</div>
</div>
</body>
</html>