Answer the question
In order to leave comments, you need to log in
Krakozyabry instead of text ajax jquery and java servlet?
I send a JSON post request using Jquery, in a servlet I receive it using Gson with the line:
JsonObject data = new Gson().fromJson(request.getReader(), JsonObject.class);
String firstName= data.get("firstName").getAsString();
...
let firstName = $("#ClientFirstNameForm").val();
let lastName = $("#ClientLastNameForm").val();
$.ajax({
method: "POST",
url: "/registerNewClient",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
data: JSON.stringify({"firstName" : firstName,
"lastName" : lastName),
dataType: 'json',
success: function(data) {
getClientList();
},
error: function(er) {
}
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question