1
votes

This code is working fine outside wordpress but Wordpress shows follwing error and does nothing. Can anyone tell the reason? Thanks

Uncaught SyntaxError: Unexpected token ILLEGAL custom_params.js:2Uncaught TypeError: Object # has no method 'prettyPhoto' chrome-extension://mpcddcfoblbgmnaklcpkbfajnfikinhn/videodownload.js:5Uncaught TypeError: Cannot read property '0' of null 3/wordpress/?page_id=458:169Uncaught ReferenceError: addInput is not defined

<script type="text/javascript">
var counter = 1;
var limit = 3;
function addInput(divName){
     if (counter == limit)  {
          alert("You have reached the limit of adding " + counter + " inputs");
     }
     else {
          var newdiv = document.createElement('div');
          newdiv.innerHTML = "Entry " + (counter + 1) + " <br><input type='text' name='myInputs[]'>";
          document.getElementById(divName).appendChild(newdiv);
          counter++;
     }
}
</script>
<form method="POST">
     <div id="dynamicInput">
          Entry 1<br><input type='text' name='myInputs[]'>
     </div>
     <input type='button' value='Add another text input' onClick='addInput("dynamicInput")'>
</form>
1

1 Answers

2
votes

Uncaught SyntaxError: Unexpected token ILLEGAL

is caused by illegal characters/symbol. Usually its a invisible characters at the end of line. Try check custom_params.js line 2 for the invalid character.

This post has a good example: Uncaught SyntaxError: Unexpected token ILLEGAL for Chrome Browser

Copy paste the code snippets there into notepad, you'll see an extra "?" character at the end of the snippet code.