Hello,
i’m developing a website using webflow but i have a problem with forms.
i have this form:
<label>Cognome:</label>
<input class="w-input" id="cognome" type="text" name="cognome">
<label>Data di Nascita:</label>
<input class="w-input" id="nascita" type="date" name="nascita">
<label>Indirizzo:</label>
<input class="w-input" id="indirizzo" type="text" name="indirizzo">
<label>Città:</label>
<input class="w-input" id="citta" type="text" name="citta">
<label>Provincia:</label>
<input class="w-input" id="provincia" type="text" name="provincia">
<label>CAP:</label>
<input class="w-input" id="cap" type="text" name="cap">
<label>Email:</label>
<input class="w-input" id="email" type="email" name="email">
</div>
<div class="w-col w-col-6 w-col-stack adjust-container">
<label>Nickname:</label>
<input class="w-input" id="nickname" type="text" name="nickname">
<div id="image_preview" style="text-align:center;"><img style="max-height:400px;" id="previewing" src="../images/profile_default.png" /></div>
<label>Immagine:</label>
<input id="file" type="file" name="avatar">
<div id="message"></div>
<input class="odonto-form-button w-button" type="submit" name="submit-new-user" value="Salva">
</div>
</form>
and i would like to submit it using jquery:
$(“#add-user-form”).on(‘click’,(function(e) {
e.preventDefault();
$(“#message”).empty();
$.ajax({
url: “admin/admin_jquery.php”, // Url to which the request is send
type: “POST”, // Type of request to be send, called as method
data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
contentType: false, // The content type used when sending data to the server.
cache: false, // To unable request pages to be cached
processData:false, // To send DOMDocument or non processed data file it is set to false
success: function(data) { // A function to be called if request succeeds
$(“#message”).html(data);
}
});
}));
but it doesn’t work. When i submit the form page gets refreshed and no data is passed to the php script. Any idea?