On the onchange
event on the dropdown list I called a JavaScript method. In this JavaScript method, I called an action class using URL tag and this URL also carries value through a parameter. But when I am doing this, I always get a null value for the setter/getter
method of the action class.
My code is:
calling setbusiness()
method inside javascript from onchange
event of dropdown list and also passing value to it. Alert messages come with id value.
But when xmlhttp.open("GET",url,true)
called then action class is called with
setter method with null value. I don't understand why the value is not coming.
Please help me how can I assign dynamic value to the parameter of URL.
<script>
function setbusiness(sourceid) {
alert(" sourceid "+sourceid);
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv1").innerHTML=xmlhttp.responseText;
}
}
var url = "<c:url action="feedajax.action">
<c:param name="sourceid">"%{sid}"</c:param></c:url>";
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>