Title: ajax return value
Last modified: December 10, 2019

---

# ajax return value

 *  [lcaba](https://wordpress.org/support/users/lcaba/)
 * (@lcaba)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/ajax-return-value/)
 * 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](https://wordpress.org/support/users/lcaba/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [autotutorial](https://wordpress.org/support/users/autotutorial/)
 * (@autotutorial)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/ajax-return-value/#post-12223546)
 * `#` is selector for id
    [https://api.jquery.com/jquery.ajax/](https://api.jquery.com/jquery.ajax/)
   url: for url send data method: POST or GET.
 * After sending the data you can retrieve the value selected by the option via 
   jquery or save the data in the database to remember this setting.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/ajax-return-value/#post-12224154)
 * Use `$.param()` to serialize the data sent.

Viewing 2 replies - 1 through 2 (of 2 total)

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

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [callback](https://wordpress.org/support/topic-tag/callback/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [value](https://wordpress.org/support/topic-tag/value/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/ajax-return-value/#post-12224154)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
