3

Getting Exception parsing document error in for (var i = 0; i < Memoryval.length; i++) line.

Can anybody help?

Below is the code.

 $(".rad").click(function () {
     var Memoryval = ["Fixed"];
     var CPU = ["Fixed", "Utilization", "OwnBorrow", "Custom", "Conditional"];
     var sel = document.getElementById('ddltype');
     sel.innerHTML = "";
     if (this.value == "MEMORY") {
         for (var i = 0; i < Memoryval.length; i++) {
             var opt = document.createElement('option');
             opt.innerHTML = Memoryval[i];
             opt.value = Memoryval[i];
             sel.appendChild(opt);
         }
         $("#divOwnBorrow").hide();
         $("#divFixed").show();
         $("#divUtilization").hide();
         $("#spanid").show();

     }
     if (this.value == "CPU") {
         for (var i = 0; i < CPU.length; i++) {
             var opt = document.createElement('option');
             opt.innerHTML = CPU[i];
             opt.value = CPU[i];
             sel.appendChild(opt);
         }
         $('#ddltype option[value=OwnBorrow]').prop('selected', true);
         // $("#ddltype select").text("OwnBorrow");
         $("#divOwnBorrow").show();
         $("#divFixed").hide();
         $("#divUtilization").hide();
         $("#spanid").hide();
     }
 });
15
  • what is exact error in console ? Commented Nov 16, 2015 at 11:52
  • org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Exception parsing document: template="tabs-policy", line 61 - column 41 Commented Nov 16, 2015 at 11:52
  • May be you are missing a closing tag somewhere in "tabs-policy", Commented Nov 16, 2015 at 11:55
  • it is showing me error on for loop line '<' place. any idea? Commented Nov 16, 2015 at 11:57
  • 1
    so it's not really a javascript, html or jqueery issue then, is it - have you tried using &lt; instead of < yet? Commented Nov 16, 2015 at 12:26

1 Answer 1

1

I suspect that you have a non breaking space before Memoryval in that line, and it got removed while copy/paste to StackOverflow:

$ charinfo " " " "
U+00A0 NON-BREAKING SPACE [Zs]
U+0020 SPACE [Zs]

It is possible to write a non breaking space, for instance pressing apple icon+space on OS X will cause this character to printed. These spaces might cause problems for The Spring Framework.

Sign up to request clarification or add additional context in comments.

3 Comments

Can you please elaborate your answer? The code is copied exactly as i have, there is no changes.
When i am removing all the spaces in for loop line, it is showing me error at ';' place.
@Chirag Which is the next line or?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.