admin管理员组文章数量:1410674
I use a method in jsp page like this and the page is saved in the name of new.jsp
<%!
public void createXml(String graph) throws Exception
{
try
{
String str="dinesh"
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = builderFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
}
catch(Exception e)
{
System.out.println(e);
}
}
%>
If i call this page like this
<form method="post" action="new.jsp">
But, I want to call this method of createXml only using javascript or jquery coding because i am going add various method in the new.jsp. Any one help this to call method without calling the whole jsp page
I use a method in jsp page like this and the page is saved in the name of new.jsp
<%!
public void createXml(String graph) throws Exception
{
try
{
String str="dinesh"
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = builderFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
}
catch(Exception e)
{
System.out.println(e);
}
}
%>
If i call this page like this
<form method="post" action="new.jsp">
But, I want to call this method of createXml only using javascript or jquery coding because i am going add various method in the new.jsp. Any one help this to call method without calling the whole jsp page
Share Improve this question edited Jul 9, 2012 at 19:29 Brandon Buck 7,1802 gold badges32 silver badges51 bronze badges asked Jul 9, 2012 at 19:22 DineshkaniDineshkani 3,0037 gold badges32 silver badges45 bronze badges 3- I don't think this is possible, you can't directly interface with the server from Javascript so your only solution would be to use an Ajax request or other means of municating with the server when the user interacts with the loaded page. – Brandon Buck Commented Jul 9, 2012 at 19:27
- Please can u give give me a coding for that – Dineshkani Commented Jul 9, 2012 at 19:29
- Here's a tutorial on JSP and Ajax – Brandon Buck Commented Jul 9, 2012 at 19:41
3 Answers
Reset to default 2What you're looking for is how to create an ajax request. You can do it without jquery or easily with jQuery:
$.post('new.jsp',{ param1: 'param1value', param2: 'param2value'},function(data){
if(data){
console.log(data); // response from your server
}
});
There's a lot more info in the jQuery docs
Here use this
$.post("new.jsp", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);});
this will help you to do bination of ajax jquery jsp
http://www.cs.wcupa.edu/~rkline/Java/ajax.html
have a look
check AJAX HTML data transmission
$(function() {
$("#button").click(function() {
$.ajax({
type: "GET",
url: "handler/book_table.jsp",
data: { id: $("#sel").val() },
success: function(data) {
$("#out").html( data )
}
})
})
})
本文标签: jquerycall a jsp method from javascriptStack Overflow
版权声明:本文标题:jquery - call a jsp method from javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744991126a2636392.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论