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

114
Vistas
Error sending ajax request

Hello I'm trying to change a piece of code that I found in a google search, to do my module. The link https://www.ostraining.com/blog/joomla/search-ajax/

My code is:

My mod_ajax_handler

$js = <<<JS
(function ($) {
    $(document).on('click', 'input[type=submit]', function () {
        var value_0 = $('input[name=nome]').val(),
        var value_1 = $('input[name=email]').val(),
        var value_2 = $('input[name=contacto]').val(),
        var value_3 = $('input[name=textinfo]').val(),
            request = {
                    'option' : 'com_ajax',
                    'module' : 'ajax_insert',
                    'data_0' : value_0,
                    'data_1' : value_1,
                    'data_2' : value_2,
                    'data_3' : value_3,
                    'format' : 'raw'
                };
        $.ajax({
            type   : 'POST',
            data   : request,
            success: function (response) {
                $('.search-results').html(response);
            }
        });
        return false;
    });
})(jQuery)
JS;

And my html on the side of client

<form>
    <input type="text" name="nome" />
    <input type="text" name="email" />
    <input type="text" name="contacto" />
    <input type="text" name="textinfo" />
    <input type="submit" value="Insert articles" />
</form>
<div class="search-results"></div>

I get a SyntaxError: missing variable name in the line

var value_1 = $('input[name=email]').val(),

My first concern, can I send more than one location clauses? Second Second why the error in that specific line?

Thanks in advance for the help!!!

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You are declaring your variables in correctly. Var is a language construct that declares the following is a variable. Either change your code to use semicolons at the end of each var statements as follows:

var value_0 = $('input[name=nome]').val();
var value_1 = $('input[name=email]').val();

or remove all but the first var statement as follows:

var value_0 = $('input[name=nome]').val(),
    value_1 = $('input[name=email]').val(),
    value_2 = $('input[name=contacto]').val();
about 4 years ago · Santiago Trujillo Denunciar
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