Answers for "ajax serialize"

4

serialize and send form data jquery ajax

$.ajax({
    type : 'POST',
    url : 'url',
    data : $('#form').serialize()
}
Posted by: Guest on July-15-2020
2

jquery serialize

var datastring = $("#contactForm").serialize();
$.ajax({
    type: "POST",
    url: "your url.php",
    data: datastring,
    dataType: "json",
    success: function(data) {
        //var obj = jQuery.parseJSON(data); if the dataType is not specified as json uncomment this
        // do what ever you want with the server response
    },
    error: function() {
        alert('error handling here');
    }
});
Posted by: Guest on September-24-2020
0

how to use serialize in ajax

$.ajax({
    type : 'POST',
    url : 'url',
    data : {
        $('#form').serialize(),
        par1 : 1,
        par2 : '2',
        par3: 232
    }
}
Posted by: Guest on April-17-2021
0

get serialize data javascript

// HTML
<form id="myForm" name="myForm">
  <div>
    <label for="username">Enter name:</label>
    <input type="text" id="username" name="username">
  </div>
  <button type="button" onclick="clickMe()">Click</button>
</form>

// JS
function clickMe(){
  let myForm = document.getElementById('myForm');
  let formData = new FormData(myForm);
  console.log(formData.get('username'));
}
Posted by: Guest on December-12-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language