Is it possible to load the contents in a div through开发者_如何学Go a servlet via .load() jquery ?
I tried this
$('#getDetails').load('getDetails');
But its not working !! What can be an alternative to this ?
Thanks
Did you read the documentation? If there's one parameter, it must be a URL. getDetails
alone apparently isn't.
Your servlet has to override method doGet
, like this:
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// implementation
}
In the web.xml, you put servlet mapping, like this:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.example.myservlet.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/servlet</url-pattern>
</servlet-mapping>
</servlet>
Then, you call servlet from JQuery context, like this:
function someFunction() {
$("#yourDivId").load("./servlet");
}
Cheers!!
got it.
I changed the method of servlet to do get, and passed a parameter with servlet name.
$('#getDetails').load('getDetails?process=u');
Its working now.
Thanks ..
精彩评论