Approach 1
If you have included jquery library somewhere in your project then below the line of code shows how to imported jquery in TypeScript file:import { $ } from '../jquery-3.1.1';
Approach 2
npm install @types/jquery --save-dev
import * as $ from 'jquery';
import * as $ from 'jquery';
export class Login {
static readonly PARAM_USERNAME = "j_username";
static readonly PARAM_PASSWORD = "j_password";
login(loginId, password, sdkURL) {
let data = {
PARAM_USERNAME: loginId,
PARAM_PASSWORD: password
}
this.loginService(data);
};
logout(loginId) {
//
};
private loginService(data: any) {
console.log("inside ajax - data :: " + data);
$.ajax({
method: 'POST',
url: 'URL Here',
data: data,
async: false,
contentType: "application/x-www-form-urlencoded",
dataType: "json",
success: function (response) {
console.log(JSON.stringify(response));
},
error: function (response, status, error) {
console.log(JSON.stringify(response));
}
});
}
}
Reference
https://stackoverflow.com/questionsContinue Learning with Java Guides
Want to take your programming skills to the next level? Explore my practical Udemy courses on Java, Spring Boot, Microservices, Full-Stack Development, Docker, and Generative AI. You can also follow my structured learning roadmaps to become a professional developer.
By Ramesh Fadatare - Udemy Instructor Partner
Comments
Post a Comment
Leave Comment