All Downloads are FREE. Search and download functionalities are using the official Maven repository.

static.js.func.js Maven / Gradle / Ivy

$.ajaxSetup({
  headers : {
	  Accept : "application/vnd.formkiq.v1+json"
	}
});

function postRequest(sel, url, successmsg, failmsg, successcallback) {

	var data = sel.serialize();
	
	$.ajax({
		type : 'POST',
		url  : url + "?" + data,
		contentType: 'application/json; charset=utf-8',
		dataType    : 'json',		
		success :  function(data) {
			
			hidemessages();
			showsuccess(sel, successmsg);
			typeof successcallback === 'function' && successcallback(data);
		},
		error: function (data) {
			hidemessages();
			var text = JSON.parse(data.responseText)
			showerror(sel, failmsg + text.message);
		}
	});
}

function makeid(size) {
	var text = "";
	var possible = "abcdefghijklmnopqrstuvwxyz0123456789";

	for( var i=0; i < size; i++ ) {
		text += possible.charAt(Math.floor(Math.random() * possible.length));
	}

	return text;
}

function hidemessages() {
	$(".messagebox").hide();
}

function showerror(sel, msg) {
	$(sel).before( $( "
  " + msg + "
" ) ); } function showsuccess(sel, msg) { $(sel).before( $( "
  " + msg + "
" ) ); } function showwarning(sel, msg) { $(sel).before( $( "
  " + msg + "
" ) ); } function shownotice(sel, msg) { $(sel).before( $( "
  " + msg + "
" ) ); } function deleteForm(sel) { var type = $("#type").val(); var data = sel.serialize(); $.ajax({ type : 'POST', url : "/api/" + type + "s/delete?" + data, contentType: 'application/json; charset=utf-8', dataType : 'json', success : function(data) { hidemessages(); showsuccess(sel, "Deleted was successful"); }, error: function (data) { hidemessages(); var text = JSON.parse(data.responseText) showerror(sel, "Unable to Delete - " + text.message); } }); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy