I'm encountering some challenges implementing a JavaScript callback with namespace in a TypeScript file. I initially believed that I could directly copy JavaScript code into TypeScript, but Visual Studio's compiler is throwing multiple errors.
Do I need to convert the JavaScript to TypeScript using a lambda expression, or is there a way to suppress these error messages?
; (function (scope, $, undefined) {
'use strict';
scope.ajaxPost = function () {
$.ajax({
url: 'PassData/PostAjax',
type: "POST",
data: { 'jsonMessage': "I was passed successfully" },
async: true,
dataType: "json",
success: function (returnVal) {
alert(returnVal);
},
error: function (data) {
alert("failed");
},
});
return false;
};
}(
some.namespace('my.namespace.Calllback'),
jQuery
));