JavaScript React JS with Rails - Accessing JSON data with URL react with rails 6,react with rails api,react with

I'm learning how to use React JS with my Rails app. Disclaimer: This is the first time I am messing around with JS!

I'm following a talk by Michael Chan at Rails Conf. Everything works beautifully until I hit the CommentsContainer part, where he fetches the comments data from a Rails route. I am trying to the same thing, except on a simple Songs controller (generated with a scaffold, having name and artist as the attribute).

I am getting stuck at the part where he fetches this data with the path, I end up with a 500 error page when I try to run the code. I don't know how to debug my React code, since the browser console is just showing a 500 error.

Here's my view,

<%= react_component "SongsContainer", { songsPath: songs_path } %>

And here's my React code,

var SongsContainer = React.createClass({
componentWillMount(){
    this.fetchSongs();
    setInterval(this.fetchSongs, 1000);
},

fetchSongs() {
    $.getJSON(
        this.props.songsPath,
        (data) => this.setState({songs: data});
    );
},

getInitialState() {
    return { songs: [] };
},

render() {
    return <Songs songs={this.state.songs} />;
}
});

Any help would greatly be appreciated! I'm just looking at this 500 page not knowing what to do.

EDIT: Adding Server log

Started GET "/" for ::1 at 2015-08-11 18:19:30 +0530
Processing by SongsController#index as HTML
  Rendered songs/index.html.erb within layouts/application (0.6ms)
Completed 500 Internal Server Error in 373ms (ActiveRecord: 0.0ms)

ActionView::Template::Error (SyntaxError: unknown: Unexpected token (10:41)):
    3: <head>
    4:   <title>Albums</title>
    5:   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
    6:   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    7:   <%= csrf_meta_tags %>
    8: </head>
    9: <body>
  app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___3071413699732960348_70238909518380'
Answer:1

I'm working on a form that has 4 different ajax request and I want to check if all 4 are successful. If they all are successful I want to switch step. Im trying something like this: If i get error ...

I'm working on a form that has 4 different ajax request and I want to check if all 4 are successful. If they all are successful I want to switch step. Im trying something like this: If i get error ...

  1. variable value jquery
  2. change variable value jquery
  3. get variable value jquery
  4. set variable value jquery
  5. update variable value jquery
  6. check variable value jquery
  7. css variable value jquery
  8. refresh variable value jquery
  9. add variable value jquery
  10. use variable value jquery
  11. access variable value jquery
  12. input value variable jquery
  13. change global variable value jquery
  14. php variable jquery value
  15. option value variable jquery
  16. attribute value variable jquery
  17. reset value variable jquery
  18. alert variable value in jquery
  19. display variable value in jquery
  20. print variable value in jquery

I want to open a popup when the user closes the last tab of the current site. The problems I have is that when the browser prompts the user (onbeforeunload returning a non null value), then the popup ...

I want to open a popup when the user closes the last tab of the current site. The problems I have is that when the browser prompts the user (onbeforeunload returning a non null value), then the popup ...

  1. javascript open popup window
  2. javascript open popup window center
  3. javascript open popup window without address bar
  4. javascript open popup with html
  5. javascript open popup after 5 seconds
  6. javascript open popup modal
  7. javascript open popup window with html
  8. javascript open popup with url
  9. javascript open popup browser window
  10. javascript open popup on page load
  11. javascript open popup new window
  12. javascript open popup window chrome
  13. javascript open popup on click
  14. javascript open popup with text
  15. javascript open popup window onclick
  16. javascript open popup window full screen
  17. javascript open popup window on page load
  18. javascript open popup in same window
  19. javascript open popup and close window
  20. javascript open popup only once

I have a div and I am trying to display a text with bold font as follows: $('#div').text("data between "+ fromdate + "to" + todate).css({'text-align':'centre'}); How do I display only "fromdate" and ...

I have a div and I am trying to display a text with bold font as follows: $('#div').text("data between "+ fromdate + "to" + todate).css({'text-align':'centre'}); How do I display only "fromdate" and ...

  1. change style inside iframe
  2. change style inside div
  3. change style inside html
  4. css change style inside iframe
  5. jquery change style inside iframe
  6. change element style inside iframe
  7. change font style inside table html
  8. change css style inside html
  9. html change style inside span

I have a HTML structure like this: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <table id ="x"> <tr> <td class='col1'> ...

I have a HTML structure like this: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <table id ="x"> <tr> <td class='col1'> ...