- get Form with id
- create formdata with Form ID
- send Data with $.ajax
My code:
<form id="company">
<input type="text" name="name" />
<input type="tel" name="tel" />
<input type="button" id="send" name="send" value="send" />
</form>
<script>
##get Form id an create form data##
var testForm = document.getElementById('send');
testForm.onclick = function(event) {
var formData = new FormData(document.getElementById('company'));
##this is Ajax Method##
$.ajax({
url : './json/company.php',
method : 'POST',
data : formData,
timeout : 10,
dataType :'json',
success: function(data)
{
alert("Success");
}
});
}
</script>
Error : TypeError: Argument 1 of FormData.constructor is not an object