This is example could be a .jsp page:
<%--
Document : pseudoservice
Created on : Dec 3, 2014, 9:38:40 AM
Author : tjaeschke
--%>
<%@page contentType="text/html; charset=UTF-8"%>
<%
String foo = request.getParameter("foo");
String bar = request.getParameter("bar");
String result = foo + bar;
request.setAttribute("result", result);
%>
${result}
Talk to it and back like this:
var pseudoServiceData = new Object();
pseudoServiceData.foo = "baz";
pseudoServiceData.bar = "qux";
$.ajax({
url: "http://www.example.com/pseudoservice.jsp",
type: "POST",
data: pseudoServiceData,
success: function(data) {
$('#whatever').html(data);
},
error: function() {
$('#whatever').html("Oh no!");
}
});
No comments:
Post a Comment