How to call AJAX request on dropdown change event?

后端 未结 2 2101
终归单人心
终归单人心 2020-12-11 09:36

index.php




        
2条回答
  •  天涯浪人
    2020-12-11 09:55

    Change your code like this:

    jQuery('#dropdown_id').live('change', function(event) {
        jQuery.getJSON($(this).val(), function(snippets) {
            for(var id in snippets) {
                // updated to deal with any type of HTML
                jQuery('#' + id).html(snippets[id]);
            }
        });
    });
    

    And your dropdown should look like this:

    
    

提交回复
热议问题