Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
How do you Use jQuery with Node Express App POST

I am trying to simply use jQuery in my npm project on the server side. I want to be able to change the values in my HTML/set them via my database. But i cannot for the life of me figure out how to declare or require the needed variables. Please help and explain!

var jsdom = require("jsdom");
var JSDOM = jsdom.JSDOM;
var window = new JSDOM("${__dirname}/homepage/index.html").window;
global.document = window.document;
const $ = require( "jquery" )( window );
//Test upload to mongodb
//Get Random Index of 'Released Pokemon' For It's Pokedex #ID
const releasedPokemon = [1,4,7,10,13,16,19,21,23,25,27,29,32,35,37,39,41,43,46,48,50,52,54,56,58,60,63,66,69,72,74,77];
app.post('/catch', async function(req, res) {
    //Catch random pokemon
    $(document).ready('#catchPokemon').hide(300);
    const index = Math.floor(Math.random() * releasedPokemon.length);
    const dex = releasedPokemon[index];
    const pokemon = await PokeAPI.pokeAPI(dex)
    console.log(pokemon);
});
<form method="post" action="/catch">
                        <button style="background-color: Transparent;" onclick="catchPokemon()">
                            <img type="image" src="https://i.imgur.com/zs02wMs.png" alt="Catch Pokemon"
                                width="100" height="100">
                            </button>
                    </form>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda