$(document).ready(function () {
$('#saveRecordCustomerInfoBtn').click(function () {
var customerId = $('#customerId').val();
var customerName = $('#customerName').val();
if (!customerId) {
showErrTip('0');
} else if (!customerName) {
showErrTip('1');
} else {
type = 'POST';
url = '/post_saveRecordCustomer/';
postData = {
"customerId": customerId,
"customerName": customerName
};
callback = function (data) {
showErrTip(data);
};
requestAjax(type, url, postData, callback);
}
})
});
function requestAjax(type, url, requestData, callback) {
$.ajax({
type: type,
url: url,
data: requestData,
dataType: 'json',
success: function (data, tetxStatus) {
ajaxSuccess(data, callback);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
})
}
function ajaxSuccess(data, callback) {
return callback(data);
}