简体   繁体   English

配置Ajax调用以从Json Rest API进行服务器端数据过滤

[英]Configure Ajax call for Server-side filtering of Data from Json Rest API

I use ajax jquery call to fetch data about tests from Jenkins test report's REST API. 我使用ajax jquery调用从Jenkins测试报告的REST API中获取有关测试的数据。 However, I want only those tests for which 'status' is not PASSED and FIXED. 但是,我只希望那些“状态”未通过和固定的测试。 Now, can I configure my Ajax call such that this filtering is already done on the server side, so that passed tests are not returned as a part of the response ? 现在,我可以配置Ajax调用,以便在服务器端已经完成此过滤,以使通过的测试不作为响应的一部分返回吗? My Ajax call so far : 到目前为止,我的Ajax电话是:

    function getTestResultsForJob(jobTestResultsUrl){

        var listOfFailures = {};
        $.ajax({
            type: 'GET',
            dataType: 'json',
            url: jobTestResultsUrl,
            async: false,
            error: function() {
                alert("Request has failed for " + jobTestResultsUrl);
            },
            success: function(data){
                console.log('Request is success for ' + jobTestResultsUrl);
                listOfFailures = data;
            }
        });
        return listOfFailures;

    }

It isn't possible to do such filtering with json on the server side. 无法在服务器端使用json进行此类过滤。

The following returns the build numer and result: 以下返回生成编号和结果:

job/Test/api/json?tree=builds[number,result]

And doing the filtering inside the success method of you ajax call. 并在ajax调用的成功方法内进行过滤。


If you can switch to xml the query would be like that: 如果可以切换到xml,查询将如下所示:

job/Test/api/xml?tree=builds[number,result]&exclude=mavenModuleSet/build[result="PASSED"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM