Basically I have a form that submits notes on work orders. I've got it posting but now its not passing checkbox data no matter if the box is checked it still goes thru as if its not. It passed a "on"
Object { result: "on" }variable.
my ajax code.
/*global $*/
$('#noteform').submit(function(e) {
e.preventDefault();
var csrf_token = "{{ csrf_token() }}";
var data = {};
var Form = this;
$.each(this.elements, function(i, v) {
var input = $(v);
data[input.attr("name")] = input.val();
delete data["undefined"];
});
$.ajax({
type: 'POST',
url: '/ticket/add/note',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(data),
context: Form,
success: function(callback) {
console.log(callback);
$('#notes').load(' #notes');
$('#notecount').load(' #notecount');
$('input[type=text], textarea').val('');
$('input[type=checkbox]').prop("checked", false);
},
error: function() {
alert('error posting!');
}
});
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrf_token);
}
}
});
});