ajax获取数据并组装select

技术探讨  2018-01-19 10:33   7787 select ajax
    /**
    * 搜索联动
    * 
    * @param  {[type]} tag     标签
    * @param  {[type]} url     ajax 请求地址
    * @param  {[type]} param   参数
    * @param  {[type]} key     key
    * @param  {[type]} default 默认值
    * @return {[type]}         
    */
    function appendHtmls(tag,url,param,option,select)
    {
         var option  = arguments[3] ? arguments[3] : {id: 'id', name: 'name'};
         var select  = arguments[4] ? arguments[4] : 0;
         $.post(url, param, function (data)
         {
             var html = "";
             if(data.status > 0 || data.code > 0)
             {
                 var items = data.data;
                 for (key in items)
                 {
                      if (select !== 0 && items[key][option.id] == select)
                      {
                      html += ""; 
                      } else {
                      html += "";
                      }  
                 }
                 $("#" + tag).html(html);
             } else {
                 return false;
             }
         })
     }


注:转载请注明出处为http://www.sandbean.com/article/45.html。

沙豆网 站长

追求卓越,奋斗不息!

167
文章
8814
点赞

更多文章