title: AJAX Email Signup Form + .htaccess Clean URLs problem
body: <p>I've successfully installed this jQuery-based signup form here:
  <a href="http://net.tutsplus.com/tutorials/javascript-ajax/building-a-sleek-ajax-signup-form/" rel="nofollow">http://net.tutsplus.com/tutorials/javascript-ajax/building-a-sleek-ajax-signup-form/</a></p>
  
  <p>But when I applied it to my main layout, which is PHP-based and uses clean URLs, the form works funky:
  I submit an email, and it stays at the "Please wait..." state.
  I'm guessing that it stops running the <code>$.ajax({</code> line.</p>
  
  <p>The JS code is as below:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      // code using jQuery
      $(document).ready(function(){
  
          $('#newsletter-signup').submit(function(){
  
              //check the form is not currently submitting
              if($(this).data('formstatus') !== 'submitting'){
  
                  //setup variables
                  var form = $(this),
                      formData = form.serialize(),
                      formUrl = form.attr('action'),
                      formMethod = form.attr('method'), 
                      responseMsg = $('#signup-response');
  
                  //add status data to form
                  form.data('formstatus','submitting');
  
                  //show response message - waiting
                  responseMsg.hide()
                             .addClass('response-waiting')
                             .text('Please Wait...')
                             .fadeIn(200);
  
                  //send data to server for validation
                  $.ajax({
                      url: formUrl,
                      type: formMethod,
                      data: formData,
                      success:function(data){
  
                          //setup variables
                          var responseData = jQuery.parseJSON(data), 
                              klass = '';
  
                          //response conditional
                          switch(responseData.status){
                              case 'error':
                                  klass = 'response-error';
                              break;
                              case 'success':
                                  klass = 'response-success';
                              break;  
                          }
  
                          //show reponse message
                          responseMsg.fadeOut(200,function(){
                              $(this).removeClass('response-waiting')
                                     .addClass(klass)
                                     .text(responseData.message)
                                     .fadeIn(200,function(){
                                         //set timeout to hide response message
                                         setTimeout(function(){
                                             responseMsg.fadeOut(200,function(){
                                                 $(this).removeClass(klass);
                                                 form.data('formstatus','idle');
                                             });
                                         },3000)
                                      });
                          });
                      }
                  });
              }
  
              //prevent form from submitting
              return false;
          });
      });
  
   // end noConflict wrap
  &lt;/script&gt;
  </code></pre>
  
  <p>The HTACCESS looks something like this:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  
      RewriteEngine On
  
      # COMPANY NAVIGATION
  
          #Sends URI to index.php for parsing
          RewriteRule !\.(css|gif|jpg|png|ico|txt|xml|js|pdf|htm|zip)$ /path/to/main/folder/index.php [NC]
  
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Which passes the variables into index.php.  In index.php, I split everything into an array, and parse the URL that way:</p>
  
  <pre><code>    function create_url_array($url) {
          strip_tags($url);
          $url_array = explode("/", $url);
          array_shift($url_array); // First one is empty
          return $url_array;
      }
      $url = $_SERVER['REQUEST_URI'];
      $url_array = create_url_array($url);
  
  if($url_array[1] == "folder") { 
  // include relevant page/s etc
  }
  </code></pre>
  
  <p>I've been trying to troubleshoot this for hours and still have not found a solution.</p>
  
  <p>Any hints/helpful info would be awesome.</p>
  
  <p><strong>/* EDIT: Included Firebug Analysis */</strong></p>
  
  <p>Thanks Nathan!  I tried your suggestion and came up with the following error when I ran a test (tried submitting the form): </p>
  
  <pre><code>"uncaught exception: Invalid JSON: 
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; 
  ... 
  {"status":"success","message":"You have been signed up!"}"
  </code></pre>
  
  <p>It basically gives me the code for the entire page, all the way until the success message.  The entry DOES appear in mysql successfully.<br>
  I think the problem is really the JSON being passed...which I'm not very familiar with at all.  It seems to hiccup where htaccess/clean URL's occur.<br>
  I'm not sure where to go about fixing this.  Do you have any suggestions?</p>