javascript - Console.log and Alert not working in Chrome -


im working in google chrome servlet have following code:

public void process(string input, printwriter out)   {         system.out.println(input.indexof("\\\\"));         string json[]= input.split("\\\\");         for(int x =0; x< json.length;x++)         {             system.out.println(json.length);             //jsonprocess(json[x]);             out.println("<p class=\"json\" style =\"display:none\"> ");             out.println(json[x]);             out.println("</p>");         }         out.println("<script>"+                 "var jsonprocess= function(){\n" +                 "var jsoninfo = document.getelementbyclassname(\"json\");\n" +                 "var canvasel = document.getelementbyid(\"c\");\n" +                 "var nodesdata =[];\n"+                  "window.alert(\"this test\");\n" +                 "console.log(jsoninfo.length);\n"+                 "for(var = 0;i<jsoninfo.length; i++)\n" +                 "{\n" +                 "var json = jsoninfo[x].innerhtml;\n" +                 "if(json.source == null)\n" +                 "{\n" +                 "nodesdata.push([json.x, json.y, json.r, json.id]);\n" +                 "}\n" +                 "}\n" +                 "for(var i=0; i<nodesdata.length; i++)\n" +                 "{\n" +                 "   var data = nodesdata[i];\n" +                 "   console.log(data[1]);\n" +                 "   console.log(data[2]);\n" +                 "   console.log(data[3]);\n" +                 "}\n" +                 "}</script>");   } 

while script tag throws no error, none of console.log or alerts work. tried

delete window.log

which given answer previous ask of question did nothing. console printing logs (i clicked on funnel thing check) , have closed , reopened chrome. answers supplied in other versions of question have not worked.

you'll have call function

 out.println("<script>"+     "var jsonprocess= function(){\n" +     "var jsoninfo = document.getelementbyclassname(\"json\");\n" +     "var canvasel = document.getelementbyid(\"c\");\n" +     "var nodesdata =[];\n"+      "window.alert(\"this test\");\n" +     "console.log(jsoninfo.length);\n"+     "for(var = 0;i<jsoninfo.length; i++)\n" +     "{\n" +     "var json = jsoninfo[x].innerhtml;\n" +     "if(json.source == null)\n" +     "{\n" +     "nodesdata.push([json.x, json.y, json.r, json.id]);\n" +     "}\n" +     "}\n" +     "for(var i=0; i<nodesdata.length; i++)\n" +     "{\n" +     "   var data = nodesdata[i];\n" +     "   console.log(data[1]);\n" +     "   console.log(data[2]);\n" +     "   console.log(data[3]);\n" +     "}\n" +     "}" +      "jsonprocess()" + // here     "</script>"); 

note printing javascript not practice, you'd better of putting javascript in .js file , printing single script tag source instead.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -