I am not able to parse tje Json object returned from the servlet in ajax,
I need to put json object values in there relative field
From my java code i am sending the below String in the form of JSON
String webVisitorDetails = "{"+"companyName : \""+webVisitor.getCompanyName()+ "\","+
"address : \""+webVisitor.getProfessionalAddress()+ "\","+
"city : \""+webVisitor.getCity()+ "\","+
"zipCode : \""+webVisitor.getZipCode()+ "\","+
"clientId : \""+webVisitor.getCustomerAccountNumber()+ "\"}";
In ajax
$.ajax({
url: "ships",
data: {
email: email.toString()
},
success: function(data) {
$.each(data, function(k, v) {
console.log(k + " Value " + v);
$("#city").text(v.city);
$("#zipcode").text(v.getZipCode);
$("#Adress").text(v.getProfessionalAddress);
});
},
error: function(data) {
console.log("error:", data);
},
type: "post",
datatype:"json",
});
org.jsonlibrary. github.com/douglascrockford/JSON-java