52
rated 0 times
[
57]
[
5]
/ answers: 1 / hits: 17164
/ 7 Years ago, thu, august 17, 2017, 12:00:00
I am trying to get values from form and append it to a form and then pass that value as parameter
Script
$(document).ready(function() {
$('#buttonClick').on('click', 'button',function firstCall(){
var form = new FormData();
form.append(name, test);
form.append(phone, 2245201905);
form.append(url, this_url);
var settings = {
async: true,
crossDomain: true,
url: url_path,
method: POST,
processData: false,
contentType: false,
mimeType: multipart/form-data,
data: form
}
$.ajax(settings).done(function (response) {
console.log(response);
});});
});
HTML
<form method=post id=formSample>
<div class=form-group>
<label for=name>Name</label>
<input type=text id=name placeholder=Fullname>
</div>
<div class=form-group>
<label for=phone>phone</label>
<input type=number name=phone placeholder=number>
</div>
<div id=buttonClick>
<button >Submit</button></div>
In my script I have hardcoded the value of name, phone and url and it is working by I am not able to append the value from form..
so I am looking for
form.append(name, (document.getElementById('name').value);
Also on button click I am not able to pass data as I have placed alert but I dont my code enter function
NOTE: I haven't worked on url part yet
More From » jquery