我想用 JavaScript 调用 servlet,但不知道如何调用。
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>
最佳答案
使用
document.location.href
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";
}
}
关于java - 如何在 JavaScript 中调用 servlet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20659231/