var updateMessage = "changes will take affect only after site will be restart"; function doUpdate(options, crudServiceBaseUrl, showMessage, allertMessage) { allertMessage = typeof allertMessage !== 'undefined' ? allertMessage : updateMessage; showMessage = typeof showMessage !== 'undefined' ? showMessage : true; $.ajax({ type: "PUT", url: crudServiceBaseUrl, dataType: "json", contentType: "application/json", data: JSON.stringify( options.data), success: function (result) { options.success(result); if (showMessage) window.alert(allertMessage); }, error: function (result) { options.error(result); alert("Something went wrong on doUpdate ! " + result.responseText); } }); } function doCreate(options, crudServiceBaseUrl, showMessage, allertMessage) { allertMessage = typeof allertMessage !== 'undefined' ? allertMessage : updateMessage; showMessage = typeof showMessage !== 'undefined' ? showMessage : true; $.ajax({ type: "POST", url: crudServiceBaseUrl, dataType: "json", contentType: "application/json", data: JSON.stringify(options.data), success: function (result) { options.success(result); if (showMessage) window.alert(allertMessage); }, error: function (result) { options.error(result); alert("Something went wrong on doCreate ! " + result.responseText); } }); } function doDelete(options, crudServiceBaseUrl, showMessage, allertMessage) { allertMessage = typeof allertMessage !== 'undefined' ? allertMessage : updateMessage; showMessage = typeof showMessage !== 'undefined' ? showMessage : true; $.ajax({ type: "DELETE", url: crudServiceBaseUrl, dataType: "json", contentType: "application/json", data: JSON.stringify(options.data), success: function (result) { options.success(result); if (showMessage) window.alert(allertMessage); }, error: function (result) { options.error(result); alert("Something went wrong on doDelete ! " + result.responseText); } }); }