How to give a new REDUIX item a unique ID?

I am mapping an array of data with props into a component. Then onClick I pull some of that data into redux/reducer from the rendered items, trying to render the same data – but in a different spot on the page.

My problem is (I assume?) that the ID’s are the same – I render data with keys’s/id’s that were already taken – while React wants unique ones.

I am not sure, if that’s what’s causing the problem – but I keep getting a warning that react wants unique key props.

(it’s a shop app – on click, i want to add the chosen item to a cart with redux… )

Thoughts?

Adding google map in my website | javascript does not work in my website

When i’m adding JS API of google map

   <script src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&libraries=places">

This error appear

Source map error: Error: request failed with status 404
Resource URL: http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js
Source Map URL: bootstrap.min.js.map

And this

> jQuery.Deferred exception: $(...).dateDropper is not a function @http://127.0.0.1:8000/assets/admin/js/scripts/extensions/date-time-dropper.js:20:19
j@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:29999
Deferred/then/g/</k<@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:30313
setTimeout handler*Deferred/then/g/<@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:30522
i@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:28017
fireWith@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:28783
fire@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:28819
i@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:28017
fireWith@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:28783
ready@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:31934
S@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:3:35
EventListener.handleEvent*@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:3:149
@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:220
@http://127.0.0.1:8000/assets/admin/vendors/js/vendors.min.js:2:225
 undefined

Loading failed for the <script> with source “http://127.0.0.1:8000/admin/js/scripts/pages/chat-application.js”.

Sequelize [Op.and] not working with M:N association

I have two models

Units and Filters which are related with M:N association through unit_filter table

 this.belongsToMany(Unit, {
        through: "unit_filter",
        as: "units",
      });

  this.belongsToMany(Filter, {
        through: 'unit_filter',
        as: 'filters',
      });

The goal is to fetch units which have more than 1 filter associated with and condition.

let result = await Unit.findAll({
          include: [
            {
              model: Filter,
              where: {
                id: {
                  [Op.and] : [2,252,4,80]
                }
              },
              as: 'filters',
            },
          ],
        });

The above is only working if there is only one id in the array which does not make any sense.

Seqeulize documenation states

  Post.findAll({
      where: {
       [Op.and]: [{ a: 5 }, { b: 6 }],            // (a = 5) AND (b = 6)
      }
    })

So the code I have should work theoritically. I also tried with

where: {
   [Op.and] : [{id:2},{id:252},{id:4},{id:80}]
}

which results in getting all the items from the db. It does not even care about the where condition in this case.

Would be of great help if any one points me in right direction.

Axios post method is sending a object with my data as the key and empty value rather than the whole data object itself

Alright so I’m guessing this should have a simple solution, but I can’t seem to figure it out. I made the frontend first and now I’m want to make the backend so I can connect to a database.

const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));

app.get("/", function (req, res) {
  res.send("hello");
});
app.post("/", function (req, res) {
  console.log(req.body);
});
app.listen(3001, function () {
  console.log("listening on 3001");
});

And this is the post request I’m making on my react frontend.

axios.post("http://localhost:3001/", JSON.stringify(note));

note is an object like such
{title: "",content: ""} the empty string gets filled out with submission data.

when I make the post request this is what gets logged in the console
{ '{"title":"test","content":"one"}': '' }
I had to use JSON.stringify() to show whats being passed through but without it, my output is {}

So the problem is when my object is posted it becomes the key of an object with empty values

What I want to do is simply send the whole object like so
axios.post("http://localhost:3001/", note);
so that in the backend I can tap into the values by doing req.body.title and req.body.content

Firestore fetching data twice

This is the code I currently have

async function getOrders() {
  const querySnapshot = await getDocs(collection(db, "orders"));
  querySnapshot.forEach((doc) => {
    // doc.data() is never undefined for query doc snapshots
    console.log(doc.id, " => ", doc.data());

  });
}

When I call this function, firestore fetches twice. I put another console.log to check if I called the function twice and I didn’t. I currently have only 1 item in firestore, and it shows two (they are duplicates). Please check the code above and the pics downbelow.

Console Img

Firebase Firestore Img

npm ERR! 404 happened when I want to install jest

Whan, I want to install Jest this error has happened, I have the latest version of Node,

npm ERR! code E404
npm ERR! 404 Not Found – GET https://registry.npmjs.org/Jest – Not found
npm ERR! 404
npm ERR! 404 ‘Jest@*’ is not in this registry.
npm ERR! 404 This package name is not valid, because
npm ERR! 404 1. name can no longer contain capital letters
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

“Swap” using interact.js, when dragging item A from area A to area B, and area B is already populated

Is it possible the “Swap out” draggable items using InteractJS, when dragging a draggable item from a “origin” to a “target” zone?

I cannot find any reference in their Documentation https://interactjs.io/docs about this specific use case

To explain better the situation and goal I made this rough fiddle:
https://jsfiddle.net/09afor6w/

It has 2 draggable “boxes” each in a “parent box”. When dragging the first box to the second, the second should automatically swap locations with the first, instead of staying put, or at least not allow the dragged element to be superposed to the element already there.

I assumed they would have a specific “swap” feature but it does not seem so.
With the “restrict” method, I can only restrict size and area of (size and drag), but not control that no items should overlap and thus maybe use this as a workaround to create a “swap” experience.

The goal behind this is creating a UI where the user can drag and drop single form elements into different places in a restricted, “gridded” area and resize the form elements.
When dragging elements from A to B, the element from the target area should change location to the “origin” area of the dragged item, that’s all.
So if there is an easier, lighter way to do this, I am also happy to hear about.

This is the code I use.
HTML:

<div class="contain-all">
    <div class="contain-some">
        <div class="grid-snap">
          Move this box to the white target area below
        </div>
    </div>
    <div class="contain-some">
        <div class="grid-snap">
          This box should automatically swap place with the moved box
        </div>
    </div>
</div>

JS:

var elements = document.getElementsByClassName('grid-snap');
$(elements).each(function(){
var x = 0; var y = 0
    interact(this)
  .resizable({
    // resize from all edges and corners
    edges: { left: true, right: true, bottom: true, top: true },

    listeners: {
      move (event) {
        var target = event.target
        var x = (parseFloat(target.getAttribute('data-x')) || 0)
        var y = (parseFloat(target.getAttribute('data-y')) || 0)

        // update the element's style
        target.style.width = event.rect.width + 'px'
        target.style.height = event.rect.height + 'px'

        // translate when resizing from top or left edges
        x += event.deltaRect.left
        y += event.deltaRect.top

        target.style.transform = 'translate(' + x + 'px,' + y + 'px)'

        target.setAttribute('data-x', x)
        target.setAttribute('data-y', y)
      }
    },
    modifiers: [
      // keep the edges inside the parent
      interact.modifiers.restrictEdges({
        outer: 'parent'
      }),

      // minimum size
      interact.modifiers.restrictSize({
        min: { width: 100, height: 50 }
      })
    ],

    inertia: true
  })
  .draggable({
    listeners: { move: window.dragMoveListener },
    inertia: true,
    modifiers: [
      interact.modifiers.restrictRect({
        restriction: '#formthing',
      }),
      interact.modifiers.snap({
        targets: [
          interact.snappers.grid({ x: 30, y: 30 })
        ],
        range: Infinity,
        relativePoints: [ { x: 0, y: 0 } ]
      }),
    ]
  })
  .on('dragmove', function (event) {
    x += event.dx
    y += event.dy

    event.target.style.transform = 'translate(' + x + 'px, ' + y + 'px)'
  })
});

Vue.js can’t v-bind:multiple in

<script>
export default {
  props: { multiple: { type: Boolean, default: false } }
}
</script>

<template>
  <input type="file" :multiple="multiple" />
</template>

does not work. Maybe because Vue sets the attribute after the DOM is build. And HTML does not recheck for attributes.

How do I fix this? I already tried v-once and duplicating the input element with a v-if, both failed. I need to set the multiple Attribute dynamically on component creation.

thank you.

trigger windows key + period with jquery or js [duplicate]

Since Windows 10 there is an integrated emoji collection that can be accessed with a combination (Windows logo key + . (period))

What I am trying to figure out is if there is a way to trigger that combination on an element click with either jQuery or pure JS.

I have tried searching to see if someone already has a solution for that, but can’t seem to find anything apart from that thread Is it possible to simulate key press events programmatically? but not sure how to do it.

So, for example, let say that with have this element <span id="emoji">Open Emoji</span>, how do we trigger (Windows logo key + . (period)) on click?

How to insert big HTML block in Javascript? Django JS

I have custom.js file in my django website. I need to create django – div in .js

catalog.html

                <div class="row px-3" id="products-section">

                       #-----------------
                       # This block should be placed from js
                       #-----------------
                        <div class="col-sm-4">
                            <article class="post post-medium border-0 pb-0 mb-5">
                                <div class="post-image">
                                    <a href="{% url 'product' product.url %}">
                                        <img src="media/{{product.img}}" class="img-fluid img-thumbnail img-thumbnail-no-borders rounded-0" alt="" />
                                    </a>
                                </div>

                                <div class="post-content">
                                    <h2 class="font-weight-semibold text-5 line-height-6 mt-3 mb-2"><a href="{% url 'product' product.url_dop %}">{{product.name}}</a></h2>

                                    <p>{{product.description}}</p>

                                    <div class="post-meta">
                                        <span><i class="far fa-user"></i> by <a href="{% url 'brandpage' product.manufacturer_url %}">{{product.manufacturer_name}}</a> </span>
                                        <span class="d-block mt-2"><a href="{% url 'product' product.url %}" class="btn btn-xs btn-light text-1 text-uppercase">Подробнее</a></span>
                                    </div>

                                </div>
                            </article>
                        </div>
                       #-----------------
                       # End block
                       #-----------------

                </div>

custom.js

var parent_div = document.getElementById("products-section");
var product_node = document.createElement("div");
product_node.className = "col-sm-4";
product_node.innerHTML = "Big html block here";
parent_div.append(product_node);

How i can add so big block? And also i need to replace django variables by js variables in this block.

How do I get the previous button to work as a undo button for each Tic Tac Toe move?

Why is it that when I recordBoardState(), the previous pushed board to boardState is updated to the latest board in the Google Chrome Live Server? This is preventing my previousMove() from applying the changes to the HTML document. Is there something I can do that will prevent this from happening?

let board = [
  ["", "", ""],
  ["", "", ""],
  ["", "", ""]
]


const boardState = []

var square1 = document.getElementById("square1")
square1.addEventListener("click", function(el) {
  if (turnMove() % 2 === 0) {
    square1.innerHTML = "X"
    board[0].splice(0, 1, "X")
  } else {
    square1.innerHTML = "O"
    board[0].splice(0, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square2 = document.getElementById("square2")
square2.addEventListener("click", function(el) {
  if (turnMove() % 2 === 0) {
    square2.innerHTML = "X"
    board[0].splice(1, 1, "X")
  } else {
    square2.innerHTML = "O"
    board[0].splice(1, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square3 = document.getElementById("square3")
square3.addEventListener("click", function(el) {
  if (turnMove() % 2 === 0) {
    square3.innerHTML = "X"
    board[0].splice(2, 2, "X")
  } else {
    square3.innerHTML = "O"
    board[0].splice(2, 2, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square4 = document.getElementById("square4")
square4.addEventListener("click", function(el) {
  if (turnMove() % 2 === 0) {
    square4.innerHTML = "X"
    board[1].splice(0, 1, "X")
  } else {
    square4.innerHTML = "O"
    board[1].splice(0, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square5 = document.getElementById("square5")
square5.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square5.innerHTML = "X"
    board[1].splice(1, 1, "X")
  } else {
    square5.innerHTML = "O"
    board[1].splice(1, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square6 = document.getElementById("square6")
square6.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square6.innerHTML = "X"
    board[1].splice(2, 2, "X")
  } else {
    square6.innerHTML = "O"
    board[1].splice(2, 2, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square7 = document.getElementById("square7")
square7.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square7.innerHTML = "X"
    board[2].splice(0, 1, "X")
  } else {
    square7.innerHTML = "O"
    board[2].splice(0, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square8 = document.getElementById("square8")
square8.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square8.innerHTML = "X"
    board[2].splice(1, 1, "X")
  } else {
    square8.innerHTML = "O"
    board[2].splice(1, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square9 = document.getElementById("square9")
square9.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square9.innerHTML = "X"
    board[2].splice(2, 2, "X")
  } else {
    square9.innerHTML = "O"
    board[2].splice(2, 2, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})



// const turnMove = () => turns++;
let turns = 0;

function turnMove() {
  return turns++
}

function checkRowWin() {
  board.forEach((row, index) => {
    if (row.toString() === "X,X,X") {
      if (index === 0) {
        square1.style.backgroundColor = "yellow"
        square2.style.backgroundColor = "yellow"
        square3.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      } else if (index === 1) {
        square4.style.backgroundColor = "yellow"
        square5.style.backgroundColor = "yellow"
        square6.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      } else {
        square7.style.backgroundColor = "yellow"
        square8.style.backgroundColor = "yellow"
        square9.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      }
    }
    if (row.toString() === "O,O,O") {
      if (index === 0) {
        square1.style.backgroundColor = "yellow"
        square2.style.backgroundColor = "yellow"
        square3.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      } else if (index === 1) {
        square4.style.backgroundColor = "yellow"
        square5.style.backgroundColor = "yellow"
        square6.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      } else {
        square7.style.backgroundColor = "yellow"
        square8.style.backgroundColor = "yellow"
        square9.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      }
    }
  })
}


function checkColWin() {
  if (board[0][0] === "X" && board[1][0] === "X" && board[2][0] === "X") {
    square1.style.backgroundColor = "yellow"
    square4.style.backgroundColor = "yellow"
    square7.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][1] === "X" && board[1][1] === "X" && board[2][1] === "X") {
    square2.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square8.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][2] === "X" && board[1][2] === "X" && board[2][2] === "X") {
    square3.style.backgroundColor = "yellow"
    square6.style.backgroundColor = "yellow"
    square9.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][0] === "O" && board[1][0] === "O" && board[2][0] === "O") {
    square1.style.backgroundColor = "yellow"
    square4.style.backgroundColor = "yellow"
    square7.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][1] === "O" && board[1][1] === "O" && board[2][1] === "O") {
    square2.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square8.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][2] === "O" && board[1][2] === "O" && board[2][2] === "O") {
    square3.style.backgroundColor = "yellow"
    square6.style.backgroundColor = "yellow"
    square9.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
}

function checkDiagWin() {
  if (board[0][0] === "X" && board[1][1] === "X" && board[2][2] === "X") {
    square1.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square9.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][2] === "X" && board[1][1] === "X" && board[2][0] === "X") {
    square3.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square7.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][0] === "O" && board[1][1] === "O" && board[2][2] === "O") {
    square1.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square9.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][2] === "O" && board[1][1] === "O" && board[2][0] === "O") {
    square3.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square7.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
}

function resetGame() {
  const squares = document.getElementsByClassName("square")
  for (let i = 0; i < squares.length; i++) {
    squares[i].textContent = ""
    squares[i].style.backgroundColor = "aliceblue"
  }
  for (let i = 0; i < board.length; i++) {
    board[i].splice(0, 3, ["", "", ""])
  }
  document.getElementById("buttons").style.display = "none"
  boardState = []
  console.log(board)
  console.log(boardState)
}

function recordBoardState() {
  boardState.push(board)
  console.log(boardState)
}

function previousMove() {
  boardState.pop()
  square1.textContent = boardState[boardState.length - 1][0][0]
  square2.textContent = boardState[boardState.length - 1][0][1]
  square3.textContent = boardState[boardState.length - 1][0][2]
  square4.textContent = boardState[boardState.length - 1][1][0]
  square5.textContent = boardState[boardState.length - 1][1][1]
  square6.textContent = boardState[boardState.length - 1][1][2]
  square7.textContent = boardState[boardState.length - 1][2][0]
  square8.textContent = boardState[boardState.length - 1][2][1]
  square9.textContent = boardState[boardState.length - 1][2][2]
  console.log(boardState)
  const squares = document.getElementsByClassName("square")
  for (let i = 0; i < squares.length; i++) {
    squares[i].style.backgroundColor = "aliceblue"
  }

}
#board {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  max-width: 40%;
  height: 40vw;
  margin: auto;
  border: 2px solid black;
  text-align: center;
  font-size: 5rem;
}

.square {
  background-color: aliceblue;
  border: 1px solid black;
}

#buttons {
  display: none;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
}

button {
  width: 10%;
  font-size: medium;
  margin: 1rem;
}
<html>

<head>
  <title>Tic Tac Toe Game</title>
  <link rel="stylesheet" href="style.css">
  <meta name="viewport" content="width-device-width initial-scale=1">
</head>

<body>
  <div id="board">
    <div id="square1" class="square"></div>
    <div id="square2" class="square"></div>
    <div id="square3" class="square"></div>

    <div id="square4" class="square"></div>
    <div id="square5" class="square"></div>
    <div id="square6" class="square"></div>

    <div id="square7" class="square"></div>
    <div id="square8" class="square"></div>
    <div id="square9" class="square"></div>
    <script type="text/javascript" src="script.js"></script>
  </div>

  <div id="buttons">
    <button id="previous" onclick="previousMove()">Previous</button>
    <button id="reset" onclick="resetGame()">Reset</button>
    <button id="next">Next</button>
  </div>
</body>

</html>

JavaScript encrypted xml throws error in JAVA application decryption: Given final block not properly padded. Such issues can arise if a bad key is

we have a sender application (node.js) which sends to a JAVA application some symmetric encrypted XML strings with an AES 128 key.

When the JAVA application tries to decrypt the content with the provided key the following error will be thrown:

javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
at com.sun.crypto.provider.CipherCore.unpad(CipherCore.java:975) at
com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1056)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:853) at
com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446) at
javax.crypto.Cipher.doFinal(Cipher.java:2168)

public generateKey(): Buffer {
    return crypto.generateKeySync('aes', { length: 128 }).export();
  }

// Encrypt content with key
public encryptSymmetric(content: string, encryptionKey: Buffer): Buffer {
    const iv = Buffer.from(crypto.randomBytes(this.IV_LENGTH)).toString('hex').slice(0, this.IV_LENGTH);
    const cipher = crypto.createCipheriv('aes-128-cbc', encryptionKey, iv);
    let encrypted = cipher.update(content);

    encrypted = Buffer.concat([encrypted, cipher.final()]);
    return encrypted;
    //return iv + ':' + encrypted.toString('hex');
  }

JAVA RECEIVER: Decrypt with key

private static byte[] decryptContent(SecretKeySpec key, byte[] content) throws GeneralSecurityException {
        Cipher cipher = Cipher.getInstance('AES');
        cipher.init(Cipher.DECRYPT_MODE, key);
        return cipher.doFinal(content); // EXCEPTION
      }

I have no idea to solve this specfi problem, at encryption level there many different optins like AES CBC or GCM, hope you can help me, we can change only the sender code!

SOAP Request with WSSE-Header in Javascript

I have the following code to execute a SOAP request with an wsse header but it seems not to work. I get a error response but I am not able to get the fault/error out of the response.

Does the below code look correct or do I miss something?

var request = "<soapenv:Envelope" +
    "xmlns:dlg='http://dlg123Lib'" +
    "xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
    "<soapenv:Header>" +
        "<wsse:Security" +
            "xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'" +
            "xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>" +
            "<wsse:UsernameToken wsu:Id='UsernameToken-BF09AFF37A2C36D4AB164000000000000000'>" +
                "<wsse:Username>BLABLABLA</wsse:Username>" +
                "<wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>BLABLABLA</wsse:Password>" +
            "</wsse:UsernameToken>" +
        "</wsse:Security>" +
    "</soapenv:Header>" +
    "<soapenv:Body>" +
        "<dlg:getData>" +
            "<name>AB</name>" +
        "</dlg:getData>" +
    "</soapenv:Body>" +
"</soapenv:Envelope>"

jQuery.ajax({
        url: 'https://endpoint_url/dlg/data',
        type: "POST",
        data: request,
        dataType: "xml",
        contentType: "text/xml; charset='utf-8'",
        success: function (soapResponse) {
            alert("Success");
        },
        error: function (soapResponse) {
            alert("Error");
        }
});

thank you for any hint!

how to datatable select2 dropdown filter

enter image description here
enter image description here

initComplete: function () {
this.api().columns().every( function () {

            var select = $('<select  class="form-control select2 "><option value=""></option></select>');
                .appendTo( $(column.header()).empty() )
                .on( 'change', function () {
                    var val = $.fn.dataTable.util.escapeRegex(
                        $(this).val()
                    );

                    column
                        .search( val ? '^'+val+'$' : '', true, false )
                        .draw();
                } );
                
            column.data().unique().sort().each( function ( d, j ) {
                select.append( '<option value="'+d+'">'+d+'</option> ' )
            } );
           
        
        } );
        
    },

Transfer a onedimensional Array from .txt with more than one Value for each element into Javascript

I have been working on a Snake game and wanted to visualize it not only in python but also on a Website. So now I have the body of my snake (coordinates for each body part) wrote into a .txt file but I am not quite sure if I can transfer this sort of Array to JS because I am not very experienced in JS.

In case this sort of Array is not transferable to JS, is there another way i could visualize an Array like this?

Example of a 4 block long snake (one block = 20×20):
[(220, 420), (240, 420), (260, 420), (280, 420)]