{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-boston/rails-project-full-stack-app/issues/65","labels_url":"https://api.github.com/repos/ga-wdi-boston/rails-project-full-stack-app/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-boston/rails-project-full-stack-app/issues/65/comments","events_url":"https://api.github.com/repos/ga-wdi-boston/rails-project-full-stack-app/issues/65/events","html_url":"https://github.com/ga-wdi-boston/rails-project-full-stack-app/issues/65","id":116553905,"number":65,"title":"AJAX requests","user":{"login":"kaylal12","id":14267771,"avatar_url":"https://avatars.githubusercontent.com/u/14267771?v=3","gravatar_id":"","url":"https://api.github.com/users/kaylal12","html_url":"https://github.com/kaylal12","followers_url":"https://api.github.com/users/kaylal12/followers","following_url":"https://api.github.com/users/kaylal12/following{/other_user}","gists_url":"https://api.github.com/users/kaylal12/gists{/gist_id}","starred_url":"https://api.github.com/users/kaylal12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaylal12/subscriptions","organizations_url":"https://api.github.com/users/kaylal12/orgs","repos_url":"https://api.github.com/users/kaylal12/repos","events_url":"https://api.github.com/users/kaylal12/events{/privacy}","received_events_url":"https://api.github.com/users/kaylal12/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-12T14:01:42Z","updated_at":"2015-11-12T14:35:22Z","closed_at":null,"body":"Everything seems to be working with curl so now i want to create the ajax requests.\r\nI have made a working ajax request for registration so I am kind of aware of how the format will be.\r\nMy ajax request for login seems to be working but i receive a weird error.\r\n\r\n```\r\n$(\"#login\").on('submit', function(event) {\r\n    $.ajax({\r\n      method: 'POST',\r\n      url: inspire_url + '/login',\r\n      data: {\r\n        credentials: {\r\n          email: $('#user_email').val(),\r\n          password: $('#user_password').val()\r\n        }\r\n      }\r\n    }).done(function(){\r\n      $(\"#login\").hide();\r\n      $(\"#logout\").show();\r\n    }).fail(function(){\r\n      console.log(\"error\");\r\n    });\r\n  });\r\n```\r\n\r\n```\r\n User Load (0.6ms)  SELECT  \"users\".* FROM \"users\" WHERE \"users\".\"email\" = $1 LIMIT 1  [[\"email\", \"abc@abc.com\"]]\r\n  SQL (0.7ms)  UPDATE \"users\" SET \"token\" = '621eb9319c5073277d286e5aaa4f810c', \"updated_at\" = '2015-11-12 13:55:55.288396' WHERE \"users\".\"id\" = $1  [[\"id\", 2]]\r\nCompleted 200 OK in 84ms (Views: 0.4ms | ActiveRecord: 1.3ms)\r\n[2015-11-12 08:55:55] ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:14 \r\n\t/usr/local/var/rbenv/versions/2.2.3/lib/ruby/2.2.0/webrick/httpserver.rb:80:in `eof?'\r\n\t/usr/local/var/rbenv/versions/2.2.3/lib/ruby/2.2.0/webrick/httpserver.rb:80:in `run'\r\n\t/usr/local/var/rbenv/versions/2.2.3/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'\r\n```\r\n\r\nOther than this error, I am not completely sure how to create ajax requests that requires authentication (how do i take the token from the user?) "},"comment":{"url":"https://api.github.com/repos/ga-wdi-boston/rails-project-full-stack-app/issues/comments/156117419","html_url":"https://github.com/ga-wdi-boston/rails-project-full-stack-app/issues/65#issuecomment-156117419","issue_url":"https://api.github.com/repos/ga-wdi-boston/rails-project-full-stack-app/issues/65","id":156117419,"user":{"login":"gaand","id":10064043,"avatar_url":"https://avatars.githubusercontent.com/u/10064043?v=3","gravatar_id":"","url":"https://api.github.com/users/gaand","html_url":"https://github.com/gaand","followers_url":"https://api.github.com/users/gaand/followers","following_url":"https://api.github.com/users/gaand/following{/other_user}","gists_url":"https://api.github.com/users/gaand/gists{/gist_id}","starred_url":"https://api.github.com/users/gaand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaand/subscriptions","organizations_url":"https://api.github.com/users/gaand/orgs","repos_url":"https://api.github.com/users/gaand/repos","events_url":"https://api.github.com/users/gaand/events{/privacy}","received_events_url":"https://api.github.com/users/gaand/received_events","type":"User","site_admin":false},"created_at":"2015-11-12T14:35:22Z","updated_at":"2015-11-12T14:35:22Z","body":"The function passed to `.done` should accept a parameter `data` that contains a user object including a token (if you used my project2-api).  You need to save the token somewhere. "}}