[HTML is replaced when successful.]
(function(jQuery){
function byrdFormError () {
var errorHtml = '
';
jQuery(".form-response").html(
errorHtml
);
}
function byrdFormSuccess (json) {
if (!json['Status'] || json['Status'] === 'ACCEPTED') {
byrdFormError();
} else {
var successHtml = '
';
jQuery(".form-response").html(
successHtml
);
}
}
function invalidRequest (json) {
if (!json['Reason']) {
}
var errorHtml = '
';
jQuery(".form-response").html(
errorHtml
);
}
function submitPayment(formData, action, event) {
var data = {
data:formData,
action:action
}
console.log('submitPayment-data = '+data);
jQuery.ajax({
method: "POST",
dataType: "json",
url: "https://admin.bpcrc.osu.edu/Samples/Payments/CoreServices/ProcessPayment.php",
data: data,
beforeSend: function(xhr){xhr.setRequestHeader("HTTP_X_REQUESTED_WITH", "xmlhttprequest");},
success: function(json) {
console.log( JSON.stringify( json ));
byrdFormSuccess(json)
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
byrdFormError();
}
});
}
jQuery(document).ready(function() {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
console.log('form-checkValidity() = '+ form.checkValidity());
event.preventDefault();
event.stopPropagation();
var webForm = jQuery('#'+this.attributes.id.value);
var data = webForm.serialize();
var action = webForm.attr('action');
console.log('data-serialize = '+data);
submitPayment(data,action,event);
} else {
event.preventDefault();
event.stopPropagation();
var webForm = jQuery('#'+this.attributes.id.value);
var data = webForm.serialize();
var action = webForm.attr('action');
console.log('data-serialize = '+data);
submitPayment(data,action,event);
//data = jQuery(this).serialize() + "&" + jQuery.param(data);
//console.log('data-serialize = '+data);
}
form.classList.add('was-validated');
}, false);
});
console.log('validation-array = '+validation);
}, false);
})(jQuery);
[HTML is replaced when successful.]
(function(jQuery){
function byrdFormError () {
var errorHtml = '
';
jQuery(".form-response").html(
errorHtml
);
}
function byrdFormSuccess (json) {
if (!json['Status'] || json['Status'] === 'ACCEPTED') {
byrdFormError();
} else {
var successHtml = '
';
jQuery(".form-response").html(
successHtml
);
}
}
function invalidRequest (json) {
if (!json['Reason']) {
}
var errorHtml = '
';
jQuery(".form-response").html(
errorHtml
);
}
function submitPayment(formData, action, event) {
var data = {
data:formData,
action:action
}
console.log('submitPayment-data = '+data);
jQuery.ajax({
method: "POST",
dataType: "json",
url: "https://admin.bpcrc.osu.edu/Samples/Payments/CoreServices/ProcessPayment.php",
data: data,
beforeSend: function(xhr){xhr.setRequestHeader("HTTP_X_REQUESTED_WITH", "xmlhttprequest");},
success: function(json) {
console.log( JSON.stringify( json ));
byrdFormSuccess(json)
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
byrdFormError();
}
});
}
jQuery(document).ready(function() {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
console.log('form-checkValidity() = '+ form.checkValidity());
event.preventDefault();
event.stopPropagation();
var webForm = jQuery('#'+this.attributes.id.value);
var data = webForm.serialize();
var action = webForm.attr('action');
console.log('data-serialize = '+data);
submitPayment(data,action,event);
} else {
event.preventDefault();
event.stopPropagation();
var webForm = jQuery('#'+this.attributes.id.value);
var data = webForm.serialize();
var action = webForm.attr('action');
console.log('data-serialize = '+data);
submitPayment(data,action,event);
//data = jQuery(this).serialize() + "&" + jQuery.param(data);
//console.log('data-serialize = '+data);
}
form.classList.add('was-validated');
}, false);
});
console.log('validation-array = '+validation);
}, false);
})(jQuery);
-->