How to do otherwise?

0

I'm getting this error when I try to load data into the page via Ajax. Is there another way to send Json objects from the servlet to the JSP without using document.write ? error: "A parser-blockingis invoked via document.write."

Servlet:

private void recuperarValores(final HttpServletRequest request, final HttpServletResponse response) 
            throws IOException, Exception {              

            request.setCharacterEncoding("UTF-8");              
            response.setContentType("application/json");   
            PrintWriter out = response.getWriter();  

         JSONArray jsonArray = new JSONArray();
         JSONObject responseObj = new JSONObject();
        try{
            Escala_DAO e = new Escala_DAO();
        List<Escala> procedimentos = e.GetEscalaTotal("2018-01-01", "2018-01-31");

                     for (Escala obj : procedimentos) {
                         JSONObject js = new JSONObject(); 

                          js.put("jsRe", obj.getRe()); 
                          js.put("jsEntra",obj.getEntrada());                       
                          jsonArray.put(js);

                          }  
                     responseObj.put("jsonArray", jsonArray);
                     out.print(responseObj);                     

                 } catch (JSONException e) {  
        }

    }

JSP:

$.ajax({
                     dataType:'json',
                     url : './GetValores',
                     type : 'POST',                 

                    success: function(data) {

                        queryObject = eval('(' + JSON.stringify(data) + ')');
                        queryObjectLen = queryObject.jsonArray.length;
                        for(var i=0;i<queryObjectLen;i++){ 

                    var inicio = +new Date(queryObject.jsonArray[i].jsEntra);
                    var fim = +new Date(queryObject.jsonArray[i].jsSai);
                    var content = "Jovani";               

                   dados.push({
                                'start': inicio,
                                'end': fim,  
                                'content': content,
                                 'className': 'green'});              

                }

            },
                    error: function() {
                        alert("Ocorreu um erro na requisição ajax");
                    }
                });
    
asked by anonymous 27.01.2018 / 22:33

1 answer

1

After searching a lot, I discovered that the problem with document.write :

Itwasduetotwogooglelinksthatneededtobeupdated.

WhatIused:

<scripttype="text/javascript" src="http://www.google.com/jsapi"></script>google.load("visualization", "1", {packages:["corechart"]});

Solution: Replace the above links with:

<script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js"></script>

google.charts.load('current', {'packages':['corechart']});
    
28.01.2018 / 21:51