Does the Javascript extension support jQuery/ajax?

I am trying to make an ajax call from the javascript extension module and it doesn’t seem to be working.

Does that module support ajax calls?

I couldn’t find anything in the documentation.

This is one of the many variations I’ve tried in JavaScript and have had no luck. This call is to make an oAuth2 client_credentials grant for an access token. I realize its probably better to attempt this in java but I’m even worse in java than JavaScript haha. Neither the console.log() or the System.out.println() has been working, but I’m not sure if that functionality is in the JavaScript module.

var accessToken = “”;
var clientId = “ARG1”;
var clientSecret = “ARG2”;
console.log(“data”);
System.out.println(“data”);

$.ajax({
url: “https://security.lup.com.au/connect/token”,
beforeSend: function(xhr) {
xhr.setRequestHeader(“Content-Type”, “application/json”);
xhr.setRequestHeader(“Accept”, “application/json”);
},
dataType: “JSON”,
data: {
client_id: clientId,
client_secret: clientSecret,
grant_type: “client_credentials”,
scope: “oapi”
},
type: “POST”,
success: function(response) {
accessToken = response;
},
error: function(errorThrown) {
accessToken = errorThrown;
}
});

//var response = getAccessToken(clientId, clientSecret);

result = accessToken;

No.

jQuery is a browser library and Ajax is browser functionality.

The JavaScript in the module is executed on the server using Java’s interpreter.