Ajax call with XML Object :
jquery.ajax (or) $.ajax({
type: "GET",//POST
url:"../../Servlet?name=testServlet",
dataType: "xml",
cache:false,
contentType: "application/xml; charset=utf-8",
error: function(x, y, z) {
},
success: function(xmlContent) {
var $xmlCon = $(xmlContent);
$xmlCon.find('address').each(function(i, src)
{
branch = $(src).find('branch').text();
});
$xmlCon.find('room').each(function(j, category)
{
if($(category).find("gender").text() == 'Male'){
strArray.push(
{
book:parseFloat($(category).find('book').text()),
cal:$(category).find('cal').text()
}
);
}
});
}, complete : function() {
},
error : function(request, error) {
}
});
Ajax call with JSON Object :
var TestVO = {
"name" : nameVal,
"address" : addr
};
var myDataArray = new Array();
$.ajax({
url:"../../Servlet?name=testServlet",
type : "POST",
dataType : "json",
cache:false,
data :{jsonStr:JSON.stringify(TestVO)},
success: function(result){
var myData = result.resVO.dataList;
myDataArray = myData;
var len = myDataArray.length;
for (var i=0;i<len;i++){
var rool = myDataArray[i].rool;
}
}