It's all about the answers!

Ask a question

Does validation scripts allow the use of XMLHttpRequest?

Leonardo Benevides (266428) | asked Jun 18 '19, 3:26 p.m.
Hi everyone,

My client is developing a "validator" type script and came across the following question:

When a "XMLHttpRequest" object is inserted  into the script, the script stops validating on the workitem save event. The validation works on the form, it just does not work at the time of the save event.

The problem happens from the time the line "var xmlhttp = new XMLHttpRequest ();" runs.

Our question for the experts here is: does validation scripts allow the use of XMLHttpRequest?

If necessary I can upload part of the code in which the object is called.

One answer

permanent link
Davyd Norris (2.3k217) | answered Jun 18 '19, 9:43 p.m.
edited Jun 19 '19, 2:21 a.m.
You have to be very careful with this one - client side validation can use pretty much anything your browser's Javascript engine will understand *AT YOUR OWN RISK*, but the server-side Javascript engine is a lot more limited.

Not only does it not have the full set of functionality, it may also be behind firewalls, and it's also quite an old version of ECMAScript (I have just found out it doesn't support <string>.includes() or <array>.includes()).

I have found I have the most success when I use the extended dojo object jazz.client, but it really depends on what you're doing. The best thing about the jazz.client version of xhr is that it understands the Jazz authentication process.

This is what I do:


(function() {
  var jazzClient = jazz.client;

  var someFunction = function(team, role) {
     var xhrArgs = {
        url : '<my url>',
        headers : {
          'Accept' : 'application/xml'
        handleAs : 'xml'

    return jazzClient.xhrGet(xhrArgs).then(function(data) {
          return data;

EDIT: By the way you can use this check to see if the script is executing on the client or the server:
if (typeof dojo.xhrGet === 'undefined') {
  console.log('I am on the server'); //this will print in ccm.log
} else {
  console.log('I am on the server'); //this will print in the browser Dev console

Rafael Rodriguez Montes commented Jul 16 '19, 1:15 p.m.

 when I put in a calculation java script it say that there is a problem loading the script

Davyd Norris commented Jul 16 '19, 7:35 p.m.

Then you have an error in your script

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.