I am trying to make an $.ajax request using javascript in a JSF primefaces xhtml file. The returned data is my template page from primefaces. The StockServlet is not executing on the server. I believe it is being caught by the Faces servlet. Has anybody had this problem before?
<script>
function getCubeData(){
$cubeName = $("#form\\:cubeName").val();
// alert("ajax call"+$cubeName);
$.ajax({
url: 'StockServlet',
dataType: 'json',
data: {cubeName: $cubeName},
type: 'get',
cache: false,
success: function(response)
{alert("success"+response);
var infoHTML = '';
$.each(response, function(stock, stockInfo)
{
infoHTML += '<p>Symbol: ' + stock + " Company: " + stockInfo.name + ' Price: ' + stockInfo.price + '</p>';
})
$("#mycube2").innerHTML(infoHTML);
alert("infohtml"+infoHTML);
},
error: function(request, textStatus, errorThrown)
{
alert("error:" + textStatus);
},
complete: function(request, textStatus)
{
alert("complete" + request.responseText);
alert("complete" + textStatus);
}
});
}
My StockServlet is defined here
@WebServlet(asyncSupported = false, name = "StockServlet", urlPatterns = {"/StockServlet"}) public class StockServlet extends HttpServlet ........