zoukankan      html  css  js  c++  java
  • ajax处理select下拉表单

        $('#gameid').change(function() {
            var gameid = $(this).val();
            if (this.value != '') {
                $.ajax({
                    url: '/market/task/?act=ajax_get_game_server_list&gameid=' + gameid,
                    type: 'get',
                    dataType: 'json',
                    beforeSend: function() {
                        $('#load_game_server').html("<image src='http://pages.19youxi.me/admin/css/images/loading.gif'>");
                    },
                    success: function(data) {
                        if (data.errorNum == 0) {
                            var game_server_list = data.game_server_list;
                            $("#serverid").find('option').eq(1).nextAll().remove();
                            if (game_server_list) {
                                for(var i=0; i < game_server_list.length; i++) {
                                    var option = "<option value='" + game_server_list[i]['id'] + "'>" + game_server_list[i]['servername'] + "</option"
                                    $("#serverid").append(option);
                                }
                            }
                            $("#load_game_server").html("");
                        } else {
                            alert(data.errorMsg);
                        }
                    },
                    error: function() {
                        alert('未知错误!');
                    }
                });
            }
        });
          
    返回后处理data还可以用map函数处理:
    $(function() {
    
    $(".chzn-select").chosen();
    $(".chzn-select-deselect").chosen({allow_single_deselect:true});
    
    $('.chzn-choices input').autocomplete({
       source: function( request, response ) {
          $.ajax({
              url: "/change/name/autocomplete/"+request.term+"/",
              dataType: "json",
              success: function( data ) {
                 response( $.map( data, function( item ) {
                    $('ul.chzn-results').append('<li class="active-result">' + item.name + '</li>');
    
              }
           });
        }
    });
    
    
    
     
  • 相关阅读:
    spring boot 启动类 添加组件
    spirng boot 添加过滤器
    spring cloud spring-hystrix 缓存
    spring cloud spring-hystrix
    spring cloud spirng整合feign
    spring cloud feign
    cxf-client
    spring cloud客户端启用负载均衡
    spring cloud 负载均衡自定义
    VS2013 配置pthread
  • 原文地址:https://www.cnblogs.com/Alight/p/3452425.html
Copyright © 2011-2022 走看看