小编kit*_*its的帖子

如何在jQuery中使用JSON数据填充dropdownlist作为ajax响应

我正在开发一个j2ee应用程序.在我的应用程序中,我有一个下拉列表(或选择元素).我想用JSON数据填充这个下拉列表作为Ajax响应.

以下是我的代码:

服务器端代码(json_source.java),它生成JSON响应.:

package demo.model;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.*;

/**
 * Servlet implementation class json_source
 */
public class json_source extends HttpServlet {
private static final long serialVersionUID = 1L;


/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{
    JsonArray data_json=new JsonArray();

    Statement st_loginId=null;
    ResultSet rs_loginId=null;
    try
    {
        Connection con=null;

        Class.forName("oracle.jdbc.OracleDriver");

        /* Connection String for "OPERWH"(exadata) …
Run Code Online (Sandbox Code Playgroud)

javascript java ajax jquery json

13
推荐指数
1
解决办法
8万
查看次数

标签 统计

ajax ×1

java ×1

javascript ×1

jquery ×1

json ×1