Select change using AJAX
-
I am trying to use two selectors. When the first is selected, it should populate the second using records from a custom table I created within the wordpress database.
To do this I tried to use the following tutorial: https://www.1stwebdesigner.com/wordpress/implement-ajax-wordpress-themes/
The first selector name is called: parent_Select
The second selector name is called: secondary_SelectI’ve always made the assumption that the below is PHP code…I just don’t have much familiarity with Javascript and AJAX.
The following block of code is giving me problems:
$(function(){ $('#parent_Select').change(function() { var $parentID=$('#parent_Select').val(); // call ajax $("#secondary_Select).empty(); $.ajax( { url:"/wp-admin/admin-ajax.php", type:'POST', data:'action=my_special_action&selectParentID=' + $parentID, success:function(results) { / alert(results); $("#secondary_Select").removeAttr("disabled"); $("#secondary_Select").append(results); } }); }); })
Could someone please let me know what might be off? Thank you!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Select change using AJAX’ is closed to new replies.