"ajax request in typescript" Code Answer's
You're definitely familiar with the best coding language TypeScript that developers use to develop their projects and they get all their queries like "ajax request in typescript" answered properly. Developers are finding an appropriate answer about ajax request in typescript related to the TypeScript coding language. By visiting this online portal developers get answers concerning TypeScript codes question like ajax request in typescript. Enter your desired code related query in the search bar and get every piece of information about TypeScript code related question on ajax request in typescript.
ajax request in typescript
module Ajax {
export class Options {
url: string;
method: string;
data: Object;
constructor(url: string, method?: string, data?: Object) {
this.url = url;
this.method = method || "get";
this.data = data || {};
}
}
export class Service {
public request = (options: Options, successCallback: Function, errorCallback?: Function): void => {
var that = this;
$.ajax({
url: options.url,
type: options.method,
data: options.data,
cache: false,
success: function (d) {
successCallback(d);
},
error: function (d) {
if (errorCallback) {
errorCallback(d);
return;
}
var errorTitle = "Error in (" + options.url + ")";
var fullError = JSON.stringify(d);
console.log(errorTitle);
console.log(fullError);
that.showJqueryDialog(fullError, errorTitle);
}
});
}
public get = (url: string, successCallback: Function, errorCallback?: Function): void => {
this.request(new Options(url), successCallback, errorCallback);
}
public getWithDataInput = (url: string, data: Object, successCallback: Function, errorCallback?: Function): void => {
this.request(new Options(url, "get", data), successCallback, errorCallback);
}
public post = (url: string, successCallback: Function, errorCallback?: Function): void => {
this.request(new Options(url, "post"), successCallback, errorCallback);
}
public postWithData = (url: string, data: Object, successCallback: Function, errorCallback?: Function): void => {
this.request(new Options(url, "post", data), successCallback, errorCallback);
}
public showJqueryDialog = (message: string, title?: string, height?: number): void => {
alert(title + "\n" + message);
title = title || "Info";
height = height || 120;
message = message.replace("\r", "").replace("\n", "<br/>");
$("<div title='" + title + "'><p>" + message + "</p></div>").dialog({
minHeight: height,
minWidth: 400,
maxHeight: 500,
modal: true,
buttons: {
Ok: function () { $(this).dialog('close'); }
}
});
}
}
}
Source: www.codeproject.com
All those coders who are working on the TypeScript based application and are stuck on ajax request in typescript can get a collection of related answers to their query. Programmers need to enter their query on ajax request in typescript related to TypeScript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about ajax request in typescript for the programmers working on TypeScript code while coding their module. Coders are also allowed to rectify already present answers of ajax request in typescript while working on the TypeScript language code. Developers can add up suggestions if they deem fit any other answer relating to "ajax request in typescript". Visit this developer's friendly online web community, CodeProZone, and get your queries like ajax request in typescript resolved professionally and stay updated to the latest TypeScript updates.