如何使用AJAX创建动态查询

时间:2022-05-01 02:09:04

I want to create a dynamic query (Select * from <table name> where ..) using angular js, html, javascript. The drop-down should come for the conditions ('and' , 'or', etc) e.g. -> select <dropdown> from <dropdown> where <dropdown> . I am new to it. So please explain in proper example.

我想使用angular js,html,javascript创建一个动态查询(从

中选择 ,其中 。我是新手。所以请在适当的例子中解释。

中选择*,其中..)。下拉应该适用于条件('和','或'等),例如 - >从

1 个解决方案

#1


0  

$.ajax({
    type: 'POST',
    url: 'DropDownController',
    dataType: 'json',
    success: function(result) {
        $.each(result, function() {
            $("#drpDown").append(
                $('<option/>', {
                    value: this,
                    html: this
                })
            );
        });
    }
});

What happens at the endpoint is some controllerDropDownController may be if you are using Spring MVC it would be something like /DropDownController where you can write you query to call database using orm or whatever you use and returned is json which binds to the dropdown with id="drpDown"

在端点上发生的是一些controllerDropDownController可能是你正在使用Spring MVC它会像/ DropDownController那样你可以写你使用orm调用数据库或者你使用的任何东西,并返回json,它绑定到下拉列表id = “drpDown”

#1


0  

$.ajax({
    type: 'POST',
    url: 'DropDownController',
    dataType: 'json',
    success: function(result) {
        $.each(result, function() {
            $("#drpDown").append(
                $('<option/>', {
                    value: this,
                    html: this
                })
            );
        });
    }
});

What happens at the endpoint is some controllerDropDownController may be if you are using Spring MVC it would be something like /DropDownController where you can write you query to call database using orm or whatever you use and returned is json which binds to the dropdown with id="drpDown"

在端点上发生的是一些controllerDropDownController可能是你正在使用Spring MVC它会像/ DropDownController那样你可以写你使用orm调用数据库或者你使用的任何东西,并返回json,它绑定到下拉列表id = “drpDown”