0
I am trying to send an object in Json format to my Java Webservice by AJAX, but I have not succeeded, I have tested wrong formats, which are not Json’s, as "string", and the database reports error properly, and therefore should report that the object has been saved, similarly html also does not return 'Alert'. Follow my code below:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="scripts/jquery.min.js.download"></script>
<script src="scripts/jquery.imagemapster.js.download"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({
var myJSon = {"Aluno":"nome", "Respostas":[], "Sessao":[] };
type: "POST",
url: 'http://localhost:8080/Servidor/server',
dataType: "json",
data: JSON.stringify(myJSon),
sucess: function (data){
alert('Sucess');
},
error: function () {
alert('Error');
}
});
});
});
</script>
</head>
<body>
<button>Send an HTTP POST request to a page and get the result back</button>
</body>
</html>
thank you very much, now html error alert, but no appearing on the server console, I will keep looking, but again thank you
– Dr.G
I understand, so check if it is configured in the correct way your back-end sripts, a good site for studies is the official MDN and PHP. This line of PHP works with your code above: <? php print_r(json_encode($_post['Student']); ?>
– user78859
The back-end is in Java
– Dr.G
ai i don’t manjo, but edits the category up there and puts java too, tries to describe to someone to help with java on the current issue, like, how do I receive the data via Ajax with Java in the back-end.
– user78859