Forum Replies Created

Viewing 1 replies (of 1 total)
  • First off, there are some syntax errors in your code:

    You are missing the closing quotes for your $(“#secondary_Select”).empty(); line. Also, you are missing the second forward slash to comment out the alert(results); line.

    Apart from that, everything looks good in this code. There could be other problems in the html file, such as incorrect selector types or names.

    Here is your code with the errors removed:

    $(function(){
    		$('#main_cat').change(function(){
    			var $parentID=$('#parent_Select').val();
    
    			//Empty secondary categories
    			$('#secondary_Select').empty();
    
    			//Call ajax
    			$.ajax({
    				url:"/wp-admin/admin-ajax.php",
    				type:'POST',
    				data:'action=my_special_action&selectedParentID=' + $parentID,
    				success:function(results) {
    					//alert(results);
    					$('#secondary_Select').removeAttr("disabled");
    					$('#secondary_Select').append(results);
    				}
    			});
    		}
    	);
    });

    To more accurately debug javascript in the future, I recommend using Firebug. Here is a good tutorial to help you get started.

Viewing 1 replies (of 1 total)