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

111
Vistas
Ajax no envía correctamente las variables de sesión

Soy muy nuevo en AJAX y PHP y actualmente estoy trabajando en un pequeño sitio web donde inicializo objetos php como variables de sesión. Las funciones y los objetos son todos viables en php y compilados con SWIG. Cuando trato de acceder a estas variables después de llamar a AJAX, el número entero que envío funciona bien. Sin embargo, el objeto que envío se establece en 0. A continuación se muestra mi código, cualquier consejo o ayuda es muy apreciada. ¡Gracias!

A continuación se muestra el código que muestra el sitio web: index.php

 <?php session_start(); $_SESSION['w_id'] = 1; $_SESSION['wordSet'] = init_WordSet(2234); ?> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><head> <body> <form method="get" class="ajax"> <input type="text" name="w_str"> <input type="submit"> </form> <script> $('form.ajax').on('submit', function(e){ e.preventDefault(); //Issue: How to get the input from php? $.ajax({ type: "GET", url: 'includes/functions.php', data: ({w_str: 'data'}), success: function(result){ alert(result); } }); }); </script> </body> </html>

A continuación se muestra el código php que llama Ajax

 <?php session_start(); echo $_SESSION['w_id'] . ' ' . $_SESSION['wordSet']; ?>

El código para inicializar el conjunto de palabras.

 struct WordSet* init_WordSet(int totalWords){ //the total number of word blocks int arrLength = ceil((double)totalWords / (double)(sizeof(unsigned long) * NUM_BYTES)); //the hash set that contains whether all words have been, or have not been used struct WordSet *wordSet = malloc(sizeof(struct WordSet)); wordSet->words = calloc(arrLength, sizeof(unsigned long)); int i; for(i = 0; i < arrLength; i++){ //setting all the words to be unused wordSet->words[i] = 0; } wordSet->totalWords = totalWords; return wordSet; }```
over 4 years ago · Santiago Trujillo
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