• Hello, I need to select a value in a select field and then have that value to make some cases.
    The problem is that I can’t get the value.

    archive-product.php

    <select name="lc_elige_marca" id="mySelect">
        <option value="1">Elige una marca</option>

    global.js

    var $ = jQuery.noConflict();
    $(function () {
    
      $('#mySelect').change(function () {
        $.ajax({
          url: ajaxurl,
          type: 'post',
          data: {
            action: 'lc_valor_modelo',
            pagina: $('#mySelect').val()
          },
          success: function (e) {
    
          },
          error: function (e) {
          }
        })
      })
    });

    FUNCTIONS.PHP

    
    add_action("wp_enqueue_scripts", "lc_insertar_js");
    
    function lc_insertar_js(){
        
        wp_register_script('lc-miscript', get_stylesheet_directory_uri(). '/js/global.js', array('jquery'), '1', true );
        wp_enqueue_script('lc-miscript');
        
        wp_localize_script('lc-miscript','lc-vars',['ajaxurl'=>admin_url('admin-ajax.php')]);
    }
    
    add_action('wp_ajax_lc_valor_modelo','lc_valor_modelos');
    add_action('wp_ajax_nopriv_lc_valor_modelo','lc_valor_modelos');
    
    function lc_valor_modelos(){
    
    }

    How can I get the value of the choice if I choose for example RENAULT?

    tHANKS

    • This topic was modified 6 years, 6 months ago by lcaba.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘ajax return value’ is closed to new replies.