title: rails and ajax SyntaxError {stack: (...), message: "Unexpected token <"}
body: <p>I'm trying to execute a ajax every 5 seconds an get the json result. But the ajax it's not working I always get:</p>
  
  <blockquote>
    <p>SyntaxError {stack: (...), message: "Unexpected token &lt;"}</p>
  </blockquote>
  
  <pre><code>$(document).ready(function(){
    setInterval(function(){ 
    var url = "/hangout_second_user";
  
    $.ajax({
      url: url,
      type: "GET",
      data: {"username" : "someusername"},
      dataType: 'json',
      success: function(){
        alert(result);
      },
      error: function(xhr, textStatus, error) {
        console.log("Impossible to connect");
        console.log(xhr.statusText);
        console.log(textStatus);
        console.log(error);
      }
    });
    }, 5000);
  });
  </code></pre>
  
  <p>Here is the action of my controller:</p>
  
  <pre><code>def hangout_second_user
      @incoming_kid = Kid.where(username: params[:username]).first
      prueba = REDIS.smembers "hangout:#{current_kid.id.to_s}"
          if !prueba.empty?
              current_kid.set_busy_status!
              respond_to do |format|
              format.json { render json: "{url:#{prueba[0].to_s}}", success: :ok, error: false }
            end
          end
  
    end
  </code></pre>
  
  <p>UPDATE</p>
  
  <hr>
  
  <p>I changed the render format like this:</p>
  
  <pre><code>format.json { render json: prueba[0].to_json, success: :ok, error: false }
  </code></pre>
  
  <p>but I still getting and html file and that's why I'm getting an error. Any help please</p>