title: Uncaught SyntaxError: Unexpected token ILLEGAL
body: <p>I am encountering a problem similar to this:
  <a href="https://stackoverflow.com/questions/5249316/uncaught-syntaxerror-unexpected-token-jquery-help">Uncaught SyntaxError: Unexpected Token - jQuery - Help!</a></p>
  <p>I am using CakePHP 2.x to generate a jquery AJAX request. It works fine on my local setup, but fails on a production server, giving me an uncaught SyntaxError:</p>
  <p>Uncaught SyntaxError: Unexpected token ILLEGAL</p>
  <p>This is the PHP:</p>
  <pre><code>// Get the select element by its generated id attribute.
  echo $this-&gt;Js-&gt;get('#'.$equipment_code)-&gt;event(
      // Change in the dropdown selection
      'change',
      // Request an array of compatible brands (match model type)
      $this-&gt;Js-&gt;request(
          array('controller'=&gt;'builds','action'=&gt;'ajax_brands'),
          // Update the associated brand dropdown
          array('update' =&gt; $hashed_brand_code, 'dataExpression' =&gt; true, 'data' =&gt; '$(&quot;#'.$equipment_code.'&quot;).serialize()')
      )
  );
  </code></pre>
  <p>Which generates this script:</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  //&lt;![CDATA[
  $(document).ready(function () {
      $(&quot;#equipment-14-0&quot;).bind(&quot;change&quot;, function (event) {
          $.ajax({
              data:$(&quot;#equipment-14-0&quot;).serialize(), 
              dataType:&quot;html&quot;, 
              success:function (data, textStatus) {
                  $(&quot;#brand-14-0&quot;).html(data);}, 
                  url:&quot;\/proj\/eztek-dev\/builds\/ajax_brands&quot;
              });
              return false;
          });
      $(&quot;#brand-14-0&quot;).bind(&quot;change&quot;, function (event) {
          $.ajax({
              data:$(&quot;#brand-14-0,#equipment-14-0&quot;).serialize(),
              dataType:&quot;html&quot;, 
              success:function (data, textStatus) {
                  $(&quot;#model-14-0&quot;).html(data);
              }, 
              url:&quot;\/proj\/eztek-dev\/builds\/ajax_models&quot;
          });
          return false;
      });
      $(&quot;#equipment-14-2&quot;).bind(&quot;change&quot;, function (event) {
          $.ajax({
              data:$(&quot;#equipment-14-2&quot;).serialize(), 
              dataType:&quot;html&quot;, 
              success:function (data, textStatus) {
                  $(&quot;#brand-14-2&quot;).html(data);
              }, 
              url:&quot;\/proj\/eztek-dev\/builds\/ajax_brands&quot;
          });
          return false;
      });
      $(&quot;#brand-14-2&quot;).bind(&quot;change&quot;, function (event) {
          $.ajax({
              data:$(&quot;#brand-14-2,#equipment-14-2&quot;).serialize(), 
              dataType:&quot;html&quot;, 
              success:function (data, textStatus) {
                  $(&quot;#model-14-2&quot;).html(data);
              }, 
              url:&quot;\/proj\/eztek-dev\/builds\/ajax_models&quot;
          });
          return false;});
      });
  //]]&gt;
  &lt;/script&gt;
  </code></pre>
  <p>And here is the <img src="https://i.stack.imgur.com/KovOZ.png" alt="stack trace" /></p>
  <p>I'd really appreciate any help you can offer, if there is any other information that would be useful, please let me know and I will put it up here asap.</p>
  <p>Thank you!</p>
  <p>EDIT:</p>
  <p>Thank you all for your help. I have fixed the uncaught syntax error by removing unaccepted characters in the js files, however the AJAX still doesn't work on the production server. I get the following error in the console:</p>
  <pre><code>Failed to load resource: the server responded with a status of 500 (Internal Server Error) 
  {Domain name} /proj/eztek-dev/builds/ajax_brands?data%5BEzcomponent%5D%5B2%5D%5Bezmodel_type_id%5D=5
  </code></pre>
  <p><a href="https://i.stack.imgur.com/mbQTY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mbQTY.png" alt="Network requests" /></a><br />
  <sub>(source: <a href="http://resaraos.com/proj/screenshot2.png" rel="nofollow noreferrer">resaraos.com</a>)</sub></p>
  <p>Could something be going wrong with the serialize()?</p>