XML to JSON Conversion Issue – defining multiple schemas

I want to build a coding of data converter that convert XML to JSON dealing with weather files. Those weather files have multiple ‘include’ and ‘import’ and ‘schemas’.

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:iwxxm="http://icao.int/iwxxm/3.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:aixm="http://www.aixm.aero/schema/5.1.1" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://icao.int/iwxxm/3.0" version="3.0.0">
    <include schemaLocation="./common.xsd"/>
    <import namespace="http://www.aixm.aero/schema/5.1.1" schemaLocation="http://www.aixm.aero/schema/5.1.1_profiles/AIXM_WX/5.1.1b/AIXM_Features.xsd"/>
    <import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>

This is one example of my xsd files. As you can see there, it has include for schema location and several imports.

For the converter language, I am trying to use javascript or typescript.
I want to use xml4js library for this project.
I want to ask some advices how to define fetching multiple schemas/import or include.

For reference, this is my converter code:

var fs = require('fs');
var util = require('util');
var xml4js = require('xml4js');

// Most of xml2js options should still work
var options = {};
var parser = new xml4js.Parser(options);


// Default is not to download schemas automatically, so we should add it manually
var xsd = fs.readFileSync('./tests/xsd/IWXXM/airmet.xsd', {encoding: 'utf-8'});
var xml = fs.readFileSync('./tests/xml/IWXXM/airmet-A6-1a-TS.xml', {encoding: 'utf-8'});


parser.addSchema('http://icao.int/iwxxm/3.0', xsd, function (err, importsAndIncludes) { 
    // importsAndIncludes contains schemas to be added as well to satisfy all imports and includes found in xsd file
    parser.parseString(xml, function (err, result) {
        console.log(util.inspect(result, false, null));
    });
});

I want to solve that importsandincludes coding part, but i feel lost somehow.

I am not sure this is the right way to ask the question here…:( I am newbie for Stackoverflow. So if you need more resources or information please let me know!

HTML page is not visible in Angular after setting all the routes

In signup.component.html I have written this simple code

<div class="container">
    <div class="signupForm">
        <form>
            <div class="mb-3">
                <label for="fullname" class="form-label">Name</label>
                <input type="text" class="form-control" id="fullname" name="fullname" placeholder="Enter your Name "
                    aria-describedby="emailHelp">
            </div>
            <div class="mb-3">
                <label for="phone" class="form-label">Phone</label>
                <input type="text" class="form-control" id="phone" name="phone" placeholder="Enter your phone number"
                    aria-describedby="emailHelp">
            </div>
            <div class="mb-3">
                <label for="email" class="form-label">Email address</label>
                <input type="email" class="form-control" id="email" name="email" placeholder="Email address"
                    -describedby="emailHelp">
            </div>
            <div class="mb-3">
                <label for="password" class="form-label">Password</label>
                <input type="password" class="form-control" name="password" placeholder="Enter your password "
                    id="password">
            </div>

            <button type="submit" class="btn btn-primary">Submit</button>
        </form>
    </div>
</div>

And my app-routing.module.ts is this :

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
// import { AppComponent } from './app.component';
import { AboutComponent } from './components/about/about.component';
import { ContactComponent } from './components/contact/contact.component';
import { HomeComponent } from './components/home/home.component';
import { LoginComponent } from './components/login/login.component';
import { SignupComponent } from './components/signup/signup.component';
import { StoreComponent } from './components/store/store.component';

const routes: Routes = [
  {'path':'store', component:StoreComponent},
  {'path':'login', component:LoginComponent},
  {'path':'signup', component:SignupComponent},
  {'path':'home', component:HomeComponent},
  {'path':'about', component:AboutComponent},
  {'path':'contact-us', component:ContactComponent}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

And in header.component.html I am routing to signup page by this :

<li class="nav-item" >
    <a class="nav-link" routerLink="/signup">Signup</a>
</li>

But after going to signup page from header link it is giving me blank page, but after removing the form part and writing anything there, it is giving me result. Same thing is happening to my login page. Writing anything random in p or h tag it is showing, when writing this code it is not.

Please help me out because I just started learning Angular so not able to figure out.

Thanks..

Is there a way to specify only the latest part of the url in href links?

Using SvelteKit, let’s say I’m in players/<PLAYER_ID>/settings/__layout.svelte and I need two more nested pages:

  1. /profile in /players/[PLAYER_ID]/settings/profile.svelte
  2. /notifications in /players/[PLAYER_ID]/settings/notifications.svelte.

In __layout.svelte I have the links:

<a href={`/players/${player.id}settings/profile`}>Profile</a>

<a href={`/players/${player.id}settings/notifications`}>Notifications</a>

Is there a way to avoid all the links in that href?

Something like /notifications only?

Bulma variables in React.js?

I have Bulma installed in my React.js project.

I’ve got a simple component where I’m trying to customize the color:

function Colortest() {
  return (
    <div>
      <section className="hero $black">
        <h1>Color Test</h1>
      </section>
    </div>
  );
}
export default Colortest;

is-primary works, along with many other Bulma styles. When I try to use some variables, however, it doesn’t work.

Here are my “dependencies” in my root package.json file:

"dependencies": {
    "@testing-library/jest-dom": "^5.16.2",
    "@testing-library/react": "^12.1.3",
    "@testing-library/user-event": "^13.5.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.4"
  },

This is my App.js file:

import "bulma/css/bulma.min.css";
import Header from './components/Header';
import Body from './components/Body';

const App = () => {
  return (
    <div>
      <Header />
      <Body />
    </div>
  );
};

export default App;

Clearly, I’m missing something simple. What am I doing wrong?

If JSON data contains specfic name then append to div [duplicate]

I have some JSON data that I’m parsing from an excel file. The one thing I’m trying to figure out is if the First Name in the JSON data equals the name in the data of First Name, then append those data elements to a specific div. For example:

JSON Data

0: Object { "First Name": "Dave", "Last Name": "Jones", "Title": "Cool Dude"}
​
1: Object { "First Name": "Dave", "Last Name": "Simpson", "Title": "Other Dude"}
​
2: Object { "First Name": "Mike", "Last Name": "Jones", "Title": "The Guy"}
​
3: Object { "First Name": "Mike", "Last Name": "Hampton", "Title": "Worker"}
​
4: Object { "First Name": "Dave", "Last Name": "Reilly", "Title": "Person"}

JS

  $.each(jData, function (i, f) {
    var firstName = f["First Name"];
    var el =
      "<blockquote>" +
      "<p><span class='blockquote-source'><strong>" +
      f["First Name"] +
      "&nbsp;" +
      f["Last Name"] +
      "</strong><br><em>" +
      f["Title"] +
      "</em></span></p></blockquote>";

        if (firstName = "Dave") {
        $(el).appendTo("#nameDave");
        }
        if (firstName = "Mike") {
        $(el).appendTo("#nameMike");
        }
  });

HTML

<div id="nameDave"></div>

<div id="nameMike"></div>

What I’m trying to achieve is this:

<div id="nameDavid">
<blockquote>
<p><span class='blockquote-source'><strong>Dave Jones</strong><br />
<em>Cool Dude</em></span></p>
</blockquote>
<blockquote>
<p><span class='blockquote-source'><strong>Dave Simpson</strong><br />
<em>Other Dude</em></span></p>
</blockquote>
<blockquote>
<p><span class='blockquote-source'><strong>Dave Reilly</strong><br />
<em>Person</em></span></p>
</blockquote>
</div>

<div id="nameMike">
<blockquote>
<p><span class='blockquote-source'><strong>Mike Jones</strong><br />
<em>The Guy</em></span></p>
</blockquote>
<blockquote>
<p><span class='blockquote-source'><strong>Mike Hampton</strong><br />
<em>Worker</em></span></p>
</blockquote>
</div>

I’m not really sure how to validate the data correctly to put the associated data based off the first name into the specific div. The way that I have it currently, it will just put that info into the div outright (obviously). Hope that makes sense? I have a feeling that I’m probably going about this incorrectly too, so any suggestions on better formatting I’m all for as well.

styled(Component) does not apply styles on functional component

1. I have a component that is written with styled-components

2. Calling that component inside of new Styled component

3. Attach styles

Result: Styles are not applied

export const WarningBox = styled(InfoBox)`
${({ theme }) => css`
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  font-size: 12px;
  padding: 16px;
  border-radius: 4px;
  background-color: ${theme.colors.yellow[150]};
  border: 1px solid ${theme.colors.yellow[700]};

  a {
    font-family: Montserrat;
    font-weight: 500;
    color: ${theme.colors.blue[900]};
    margin-right: 15px;
  }
`}}
`;

This is InfoBox that I want to customize:

const Container = styled.div`
${({ theme }) => css`
  padding: 16px;
  width: 100%;
  min-height: 110px;
  border-radius: 4px;
  background-color: ${theme.colors.green[150]};
`}}
`;

...rest of the styled-components...

type InfoBoxProps = {
  title?: string;
  text?: string;
  icon?: React.ReactNode;
};

export const InfoBox: FC<InfoBoxProps> = ({
  title = '',
  text = '',
  icon,
  children,
}) => (
  <Container className="box-container">
    <Text>{text}</Text>
    {children}
  </Container>
);

Uncaught Error: Element ref was specified as a string (content) but no owner was set. This could happen for one of the following reasons:

So I will no longer use micro froentend to include this part of the application, so I did copy the source files into the main project. Installed packages, etc but when I went to run, I got this error on console:

Uncaught Error: Element ref was specified as a string (content) but no owner was set. This could happen for one of the following reasons:
1. You may be adding a ref to a function component
2. You may be adding a ref to a component that was not created inside a component's render method
3. You have multiple copies of React loaded
See https://reactjs.org/link/refs-must-have-owner for more information.
    at coerceRef (react-dom.development.js:13218:1)
    at createChild (react-dom.development.js:13448:1)
    at reconcileChildrenArray (react-dom.development.js:13719:1)
    at reconcileChildFibers (react-dom.development.js:14125:1)
    at reconcileChildren (react-dom.development.js:16990:1)
    at updateHostComponent (react-dom.development.js:17632:1)
    at beginWork (react-dom.development.js:19080:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at beginWork$1 (react-dom.development.js:23964:1)
    at performUnitOfWork (react-dom.development.js:22776:1)
    at workLoopSync (react-dom.development.js:22707:1)
    at renderRootSync (react-dom.development.js:22670:1)
    at performSyncWorkOnRoot (react-dom.development.js:22293:1)
    at scheduleUpdateOnFiber (react-dom.development.js:21881:1)
    at updateContainer (react-dom.development.js:25482:1)
    at react-dom.development.js:26021:1
    at unbatchedUpdates (react-dom.development.js:22431:1)
    at legacyRenderSubtreeIntoContainer (react-dom.development.js:26020:1)
    at Object.render (react-dom.development.js:26103:1)
    at Module.<anonymous> (index.js:6:1)
    at Module../src/index.js (index.js:8:1)
    at __webpack_require__ (bootstrap:851:1)
    at fn (bootstrap:150:1)
    at Object.1 (ChannelName.tsx:4:1)
    at __webpack_require__ (bootstrap:851:1)
    at checkDeferredModules (bootstrap:45:1)
    at Array.webpackJsonpCallback [as push] (bootstrap:32:1)
    at main.chunk.js:1:59

it seems i didn’t have any duplicate react version loaded:

> npm ls react
├─┬ @emotion/[email protected]
│ └── [email protected] deduped
├─┬ @emotion/[email protected]
│ └── [email protected] deduped
├─┬ @mui/[email protected]
│ └── [email protected] deduped
├─┬ @mui/[email protected]
│ ├─┬ @mui/[email protected]
│ │ └── [email protected] deduped
│ ├─┬ @mui/[email protected]
│ │ ├─┬ @mui/[email protected]
│ │ │ └── [email protected] deduped
│ │ ├─┬ @mui/[email protected]
│ │ │ └── [email protected] deduped
│ │ └── [email protected] deduped
│ ├─┬ @mui/[email protected]
│ │ └── [email protected] deduped
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ ├── [email protected] deduped
│ └─┬ [email protected]
│   └── [email protected] deduped
├─┬ @mui/[email protected]
│ └── [email protected] deduped
├─┬ @testing-library/[email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected] deduped
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├── [email protected]
└─┬ [email protected]
  └── [email protected] deduped

I didn’t have in the source code ref set to a string, only 3 uses like this:

return

the full code look like this:

import { useCallback, useState } from 'react';
import { useDrop } from 'react-dnd';
import { ItemTypes } from './ItemTypes.tsx';
import { DraggableBox } from './DraggableBox';
import update from 'immutability-helper';
import { ButtonBox, TextBox, CheckBox } from './Box';
import { ControlType } from './ControlType';
import { GiArrowCursor } from "react-icons/gi";

const styles = {
    width: 150,
    height: 400,
    border: '1px solid black',
    position: 'relative',
    background: 'RGB(240, 240, 240)'
};

const cursorPropStyle = {
    position:"absolute",
    top: 10,
    left: 10,
};

export const Container = () => {
    const [boxes, setBoxes] = useState({
       //a: { top: 20, left: 10, title: 'Button' },
    });
    
    const moveBox = useCallback((id, left, top) => {
        setBoxes(update(boxes, {
            [id]: {
                $merge: { left, top },
            },
        }));
    }, [boxes]);
    
    const [, drop] = useDrop(() => ({
        accept: ItemTypes.BOX,
        drop(item, monitor) {
            const delta = monitor.getDifferenceFromInitialOffset();
            let left = Math.round(item.left + delta.x);
            let top = Math.round(item.top + delta.y);
            moveBox(item.id, left, top);
            return undefined;
        },
    }), [moveBox]);

    return <div ref={drop} style={styles}>
                <div style={cursorPropStyle}>
                    <GiArrowCursor />
                </div>
                <DraggableBox top={30} left={10} key="a" id="a" title="button" controlType={ControlType.Button}>
                    <ButtonBox title="button"/>
                </DraggableBox>
                <DraggableBox top={60} left={10} key="b" id="b" title="" controlType={ControlType.TextBox}>
                    <TextBox/>
                </DraggableBox>
                <DraggableBox top={90} left={10} key="c" id="c" title="checkbox" controlType={ControlType.CheckBox}>
                    <CheckBox title="checkbox" />
                </DraggableBox>
            </div>;
};

How can I fix this?

NodeJs: Promise always returns undefined

So I have the following promise that is supposed to go inside my sqlite database and tell me if there is a match. Even if the variables are correct it always returns undefined.

var checkLoanable = function(bookID){
    return new Promise((resolve, reject)=>{
        
        db.run('SELECT * FROM book WHERE id=?',[bookID],(err,row)=>{
            if (err) {
                console.log("error")
                reject();
                }
            if(row){
                
                if(row.loanable==0){
                    console.log("not loanable")
                    reject();
                        
                }
                console.log("success")
                resolve(row);
            }else{
                console.log("undefined")
                reject();
                    
            }
            console.log("End of promise")
        });
    
    })
}

This is the call of the function

await checkLoanable(bookID)
        .then(()=>{console.log("success")})
        .catch(()=>{
            res.status(422)
                .setHeader('content-type', 'application/json')
                .send({ message: "Failed to add loan: book is not loanable!"});
            
        });
        console.log("after promise");
        

The await is inside an async function and after tests I did it does wait for the promise to end and then continues the code. I can’t figure out why its always undefined though.
Thank you in advance for any help.

Pointing arrow on precise location on donut chart

I am trying to point to certain parts on a donut chart.

chart is divided into 9 parts

comArray is the main array which contain all parts

angleArray are the angle in degrees for each part

useArray contains the parts that should be located through the pointer

My code is working for sometime but then it starts locating on some different point.

e.g. if pointer needs to point to “3” part. it locates properly but after 1 hour, it will start locating on “6” part for “3” part.

what I am doing wrong?

you can check the working example on link below:

https://bishttech.com/newtest/

Below is my code


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
 <meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="js/rotate.min.js"></script>
<script src="js/jquery.easing.min.js"></script>

    
<style type="text/css">
.img{
margin:48px 52px;
position:absolute;z-index:1;}


#container{
width:50%;
    display:block;
    margin: 0 auto; 
     position:relative;
    }

#chart{
    position:relative;
    z-index:20;
}
</style>
<script type="text/javascript">
$(document).ready(function()
{
var comArray = [1,2,3,4,5,6,7,8,9];  // main array of all parts
var angleArray = [20,60,100,140,180,220,260,300,340]; // angle in degrees for all parts

var useArray = [3,6,8,2]; // pointer should stop on these parts

//console.log(areacount);
var canvas=document.getElementById("chart");
var ctx=canvas.getContext("2d");


 function drawMultiRadiantCircle(xc, yc, r, radientColors) {
  var partLength = (2 * Math.PI) / radientColors.length;
  var start = 0;
  var gradient = null;
  var startColor = null,
      endColor = null;
 var startAngle = 0;
  for (var i = 0; i < radientColors.length; i++) {
    startColor = radientColors[i];
  //  endColor = radientColors[(i + 1) % radientColors.length];
endColor = adjust(startColor, -30);
    // x start / end of the next arc to draw
    var xStart = xc + Math.cos(start) * r;
    var xEnd = xc + Math.cos(start + partLength) * r;
    // y start / end of the next arc to draw
    var yStart = yc + Math.sin(start) * r;
    var yEnd = yc + Math.sin(start + partLength) * r;

    ctx.beginPath();

    gradient = ctx.createLinearGradient(xStart, yStart, xEnd, yEnd);
    gradient.addColorStop(0, endColor);
    gradient.addColorStop(0.5, startColor);
    gradient.addColorStop(1.0, endColor);

    ctx.strokeStyle = gradient;
    ctx.arc(xc, yc, r, start, start + partLength);
    ctx.lineWidth = 30;
    ctx.stroke();
    ctx.closePath();
    
              
    start += partLength;
    startAngle = partLength;
  }
 
}
var someColors = ["#fb4168","#4efb7f","#fbf672","#63e0fb","#5b5bfb","#f079fb","#e0dffb","#1aa3fb","#1aa3fb"];
drawMultiRadiantCircle(300, 300, 200, someColors);



 // get location of value
 function getCurLoc(value)
{

for(var i=0;i<comArray.length;i++)
{
if(value == comArray[i])
{
return i;
break;
}

}
}

    



var startingPnt = 0;
var curangleDegrees = 0;
var prevangleDegrees = 0;
var prevLoc = 0;
var curLoc = 0;
var rotateNum = 0;
var diffLoc = 0;
//function for displaying data on chart
function displayData()
{

var maxPnt = useArray.length-1;
var currentValue = useArray[startingPnt];

var getLoc = getCurLoc(currentValue); // getting location of value in comArray

if(rotateNum == 0)
{
curangleDegrees = angleArray[getLoc];
curLoc = getLoc;
}
else
{
curLoc = getLoc;
diffLoc = curLoc - prevLoc;
curangleDegrees = (diffLoc * 40);

}

 $(".img").rotate(curangleDegrees, {
easing: 'easeInExpo'
});
console.log(getLoc);
if(startingPnt == maxPnt)
{
startingPnt = 0;
}
else
{
startingPnt++;
}

prevLoc = curLoc;
prevangleDegrees = curangleDegrees;
rotateNum++;
}


setInterval(function() {
displayData();

 }, 10000);
 
 function adjust(color, amount) {
    return '#' + color.replace(/^#/, '').replace(/../g, color => ('0'+Math.min(255, Math.max(0, parseInt(color, 16) + amount)).toString(16)).substr(-2));
}

});
</script>
</head>
<body>
<div id="container">

    <img class='img' src="images/arrowcircle.png" alt="" />
    <canvas id="chart" width="800" height="800"></canvas>
</div>



</body>
</html>


please help me.

thanks

Is there a way to collect the length without having to create a loop of the objects collected via cheerio?

To get the amount of objects collected, I do it via looping:

function TestStackOverflow() {
    var url = 'https://int.soccerway.com/matches/2022/03/04/south-america/copa-libertadores/atletico-nacional/club-olimpia/3711950/';

    const contentText = UrlFetchApp.fetch(url).getContentText();
    const $ = Cheerio.load(contentText);

    var values = [];
  
    $('.container.left > table.playerstats.lineups.table > tbody > tr > td.player.large-link > a')
        .each((index, element) => {
            values.push([$(element).text()])
        });
    Logger.log(values.length)
}

I tried these options:

$('.container.left > table.playerstats.lineups.table > tbody > tr > td.player.large-link > a').lenght
$('.container.left > table.playerstats.lineups.table > tbody > tr > td.player.large-link > a').text.lenght
Object.keys($('.container.left > table.playerstats.lineups.table > tbody > tr > td.player.large-link > a')).length
Object.keys($('.container.left > table.playerstats.lineups.table > tbody > tr > td.player.large-link > a').text).length

But none arrived at the expected result, they all return null or error. Is there any way to proceed to speed up the process that is slow via looping?

Getting content of span element

I have initial empty array named array. In my page I have several span elements with class “inbox”. I need to get this collection of span elements and then collect their content into another array. But this line of code array[i] = values1[i].innerHTML shows error Cannot read properties of undefined (reading ‘innerHTML’) at HTMLButtonElement.btn.onclick. I can’t get it.

btn.onclick = function() {
        var values = document.getElementsByClassName("inbox")
        var values1 = Array.prototype.slice.call(values);
         
         for (i = 0; i<arrOfWords.length; i++) {
              array[i] = values1[i].innerHTML
          }
         console.log(array)
     }

simplify reduce function (function register Movements) with javascript

good afternoon.
I have this code from the javascript programming language.
They send me/I would like to reduce/simplify or optimize the code.
They send me/I would like to reduce/simplify or optimize the code.
They send me/I would like to reduce/simplify or optimize the code.

Any suggestion?
Thanks

function registerMovements(box){
let piece = document.getElementById(box).innerHTML;
let column = box.substring(0,1);
let row2 = box.substring(1,3);
switch (document.getElementById(box).textContent) { //"♙""♖""♗""♘""♕""♔"/"♟""♜""♝""♞""♛""♚"
    case "♙":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerWhitePieces").innerHTML += row;
        break;

    case "♖":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerWhitePieces").innerHTML += row;
        break;

    case "♗":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerWhitePieces").innerHTML += row;
        break;

    case "♘":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerWhitePieces").innerHTML += row;
        break;

    case "♕":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerWhitePieces").innerHTML += row;
        break;

    case "♔":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerWhitePieces").innerHTML += row;
        break;

    case "♟":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerBlackPieces").innerHTML += row;
        break;

    case "♜":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerBlackPieces").innerHTML += row;
        break;

    case "♝":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerBlackPieces").innerHTML += row;
        break;

    case "♞":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerBlackPieces").innerHTML += row;
        break;

    case "♛":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerBlackPieces").innerHTML += row;
        break;

    case "♚":
        var row = "<tr><td>"+piece+column+row2+"</td></tr>";
        document.getElementById("registerBlackPieces").innerHTML += row;
        break;
}
}

Loading a modal in Razor

Is there a way you can reference a cshtml file in a javascript file. For example I have an Index.cshtml that displays a modal to sign up. I want to reference this modal in my javascript file to display when the page is loaded.

The second ajax does not change the DOM after loading the first one jQuery

I have two very similar jquery AJAX codes. Both work correctly when I use them separately. However, if I load the first code, if I want to load the second it probably works (because I tested different places “console.log(”test”)”), but it doesn’t change the DOM. Please help.

I have tried many different solutions and none have provided a solution. I have searched on many forums but have not found an answer.

1st

    var basketAddTimeout;
var ajaxSubmitForm;
app_shop.run(function() {
    ajaxSubmitForm = function() {
        $this = $('#projector_button_basket');
        
        var url = $('#projector_form').attr('action');
        var txt = $this.text().trim();
        clearTimeout(basketAddTimeout);
        $.ajax({
            type: 'POST',
            url: url,
            data: $('#projector_form').serializeArray(),
            success: function(data) {   
                basketAddTimeout = setTimeout(function() { 
                    
                    $('#Basket').load(' #projector-basket-form');
                }, 1000)
                fetch('/ajax/basket.php').then(res => res.json()).then(({
                    basket
                }) => {
                    const number = basket.productsNumber;
                    const number12 = basket.worth_formatted;
                    $('#kwota-basket').text(number12);
                    
                    document.getElementById('badgekoszyka').style.display = 'block';
                    $( "#badgekoszyka" ).fadeOut( "slow");
                    $( "#badgekoszyka" ).fadeIn( "slow");
                    $('#menu_basket .badge').text(number);
                    $('#badgekoszyka').text(number);    
                })
            },
            error: function() {
                classObj.alert(classObj.txt.dodano_produkt_blad);
                $('#projector_button_basket').html(txt);
                $('#projector_button_basket').removeClass('loader');
            }
      });
    }
}, 'all');

second

 var basketAddTimeout2;
var ajaxSubmitForm2;
app_shop.run(function() {
    ajaxSubmitForm2 = function() {
        var url = $('#projector-basket-form').attr('action');
        $('#loaders').addClass('loader-koszyk');
        $('#blok-koszyk').css('filter','blur(3px)');
        
        clearTimeout(basketAddTimeout2);
        $.ajax({
            type: 'POST',
            url: url,
            data: $('#projector-basket-form').serializeArray(),
            success: function(data) {
                basketAddTimeout2 = setTimeout(function() {  
                        
                            
                }, 1000)
                fetch('/ajax/basket.php').then(res => res.json()).then(({
                    basket
                }) => {
                    
                    const number = basket.productsNumber;
                    const number12 = basket.worth_formatted;
                    $('#kwota-basket').text(number12);
                    $('#menu_basket .badge').text(number);
                    $('#badgekoszyka').text(number);
                    $('.topBasket').load('/basketchange.php?type=multiproduct&mode=2 .topBasket>*', function() {});
                    $('#loaders').removeClass('loader-koszyk');
                    $('#blok-koszyk').css('filter','blur(0px)');
                    document.getElementById("Basket").innerHTML = contentt;
                })
            },
            error: function() {
                classObj.alert(classObj.txt.dodano_produkt_blad);
            }
        });
    }
}, 'all')

$(document).on('click', '#usuwanie-koszyk, #dodawanie-koszyk, #usuwanie-calkowite ', function(e) {
        
    ajaxSubmitForm2();  
    e.preventDefault();
    
});