---
title: "将json元素添加到表单select中"
author: "conkeyn"
date: "2010-08-10T15:06:46Z"
tags: []
categories: ["Web前端"]
slug: "json-select"
draft: false
lastmod: "2010-08-11T07:16:11Z"
id: 733733
url: "https://conkeyn.iteye.com/blog/733733"
---

将json元素添加到表单select中。

 

```
$.ajax({type: "GET",
                   url: "ajax_get_districts.php",
                   data: "type=operators&project_id="+o.options[o.selectedIndex].value,
                   dataType: "json",
                   success: function(json){
                        for(var i = 0; i < json.length; i++)
                        {
                            $(new Option(json[i].name,json[i].id)).appendTo('#select_project');
                        }
                   }
                });
```