Issue
I want to call a servlet in JavaScript, but how to call I do not know.
function func_search()
{
var srchdata = document.getElementById('searchitem').value;
if(srchdata == "")
{
alert("Enter Search Criteria...");
}
else
{
//what to write here to call servlet ??
}
}
<a onclick="func_search();"><img src="images/srch.png" height="32px" width="32px"/></a>
Solution
document.location.href
is used
function func_search()
{
var srchdata = document.getElementById('searchitem').value;
//alert(srchdata);
if(srchdata == "")
{
alert("Enter Search Criteria...");
}
else
{
document.location.href="your servlet name here";
}
}
Answered By - Java Curious ღ