I need to send a json when a form is filled on html. I have the following html:
<head>
<title>Insert title here</title>
</head>
<body>
<form id="form">
    Nome: <input type="text" id="nome" /> 
    Idade: <input type="number" id="idade" /> 
    <input type="button" id="submit" value="submit"/>
</form>
and the following js:
src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"
var arr = {
    City : 'Moscow',
    Age : 25
};
$(document).ready(function() {
    //click on button submit
    $("#submit").on('click', function() {
        //send ajax
        $.ajax({
            url : 'http://localhost:8080/DBRest/rest/escreve',
            type : "POST", // type of action POST || GET
            dataType : 'json', // data type
            contentType : 'application/json; charset=utf-8',
            data : $("#form").serialize(), // post data || get data
            data : JSON.stringify(arr)
        })
    });
});
I have already looked for here, here and here.
I tried creating a arr variable to mock a filled form but didn't get anything either. I would like to know the difference between dataType and contentType. And about this specific line:
data : $("#form").serialize()
is this correct? There's a difference between simple and double quotes surrounding #form
 
     
     
    