Ajax request in Rails not receiving a response from the controller

After troubleshooting a simple GET request to the controller action, I confirmed that the request is being made successfully and there are no issues with the controller executing the action. However, I am not receiving any response data.

$.ajax({
  url: _url,
  type: 'GET',
  dataType: 'json',
  sucess: function(response) {
    alert(response);
    console.log("response: " + response);
  }
});
  def get_team_statuses
    @wager = Wager.find(params[:id])
    _team_count = helpers.get_team_member_names_without_self(@wager).count + 1
    _opponent_count = helpers.get_opposing_member_names(@wager).count

    _team_full = _team_count == @wager.team_size.players_count
    _opposing_team_full = _opponent_count == @wager.team_size.players_count

    respond_to do |format|
      format.html
      format.json { render json: {team_full: _team_full, opposing_team_full: _opposing_team_full } }
    end
  end

Despite reviewing various resources and documentation suggesting everything is set up correctly, the only notable message received is:

Started GET "/wagers/1b4b6da7-7dd0-4a42-b17b-3872850d908d/get-team-statuses" for ::1 at 2020-08-10 16:11:01 -0700 Processing by WagersController#get_team_statuses as JSON

[active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (0.09ms)

Completed 200 OK in 12ms (Views: 0.5ms | ActiveRecord: 2.0ms)

Any suggestions or insights?

Edit: Here's what my network tab displays for XHR requests. It shows the multiple request instances when the button was clicked three times.

https://i.sstatic.net/NXmdV.png

Answer №1

This solution should work:

$.ajax({
  url: _url,
  type: 'GET',
  dataType: 'json',
  success: function(response) {
    alert(response);
    console.log("response received: " + response);
  }
});

You have a small typo in between success and sucess

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilize FormData by passing it to a separate function and then utilizing it

I have encountered a perplexing issue with my Flask app that involves submitting a form to upload an image to the server. Despite my efforts, I have been unable to find a solution on my own. When I submit the form, I use FormData to create the necessary o ...

Troubleshooting VueJS, Electron, and Webpack integration with Hot Reload feature

I have been immersed in a new project that involves utilizing Electron, VueJS, and Webpack for HMR functionality. Unfortunately, I am encountering difficulties with the Hot Module Replacement feature not working as expected. Here is my current configurati ...

Testing for expressjs 4 using Mocha revealed unexpected behavior when attempting to spy on a function called within a promise. Despite setting up the

I have encountered a situation with some test cases structured like this: it('does stuff', function(done) { somePromise.then(function () { expect(someSpy).to.have.been.called done() }) }) When the assertion in a test case fails, it ...

Export default does not actually yield a function; rather, it returns an object

I recently developed a function that is responsible for importing a script from a specified source, calling its exported function, and handling the returned result. To simplify things, I have streamlined the code to focus solely on returning the result. co ...

Error: The variable "THREE" has not been declared or defined

Attempting to bring in the SSAO shader from three (node modules) with the following syntax: import {SSAOShader} from 'three/examples/js/shaders/SSAOShader'` Unfortunately, encountering the error message: ReferenceError: THREE is not defined ...

ajax.php form connected to a database using php

Introduction: I am currently working on a server-side datatables library. The code snippet below is not displaying either $stmt or $row, making it difficult to identify the issue. It's frustrating because I was hoping to troubleshoot this without see ...

Exploring the colors of legend navigation icons in Google Pie charts

Is there a way to customize the color of the navigation links in Google pie charts (specifically the blue text in the bottom right corner)? ...

Is it possible that bitwise left shifts in JavaScript ES6 (<<) become cyclical after surpassing a shift of 63?

From my understanding of the << bitwise left operator in JS (ES6), the void to the right is typically filled with zeros. However, through observation in both V8 and JSC, it appears that the set bits suddenly reappear when we shift by 64 or more. (2 ...

Select multiple rows by checking the checkboxes and select a single row by clicking on it in the MUI DataGrid

I am currently utilizing the MUI DataGrid version 4 component. The desired functionalities are as follows: Allow multiple selections from the checkbox in the Data Grid (if the user selects multiple rows using the checkbox). Prevent multiple selections fr ...

I'm looking for a way to track the progress of an ajax call. Specifically, I want to know how I

I am currently working on an AJAX call that executes a lengthy PHP script producing 20 different results. I aim to display the progress of each step within the script, such as 1/20 complete, 2/20 complete, 3/20 complete. Last updated on 29-12-2015 at 03:1 ...

What is the best way to bring an image into your nextjs project?

I have a question about importing images into my Next.js project. I created an array of objects and want to import an image stored in a folder on my laptop, specifically in the src folder rather than the public folder. How can I properly achieve this in ...

applying multiple conditions to filter data in javascript

I have been working on filtering data based on input, and it is functioning well. However, I am looking to add an additional condition to the filter. I want it to return if either the title or another value (such as sendFrom) is provided. const newData = ...

Choosing a recently inserted row in jqGrid

After reloading the grid, I am trying to select the newly added row, which is always added at the end. However, it seems impossible to do so after the reload. Is there a reliable way to select the last row after reloading the grid? The current code I have ...

Customize your Android WebView to show specific sections of a website

Struggling to display a specific part of a webpage in my webview, despite trying numerous solutions. class ActionFragment : Fragment() { class MyWebClient : WebViewClient() { override fun shouldOverrideUrlLoading(view: WebView, url: String): ...

Tips for extracting data from various select drop-down menus within a single webpage

As a newcomer to JQuery, I apologize if this question seems basic. I have a page with 20 categories, each offering a selection of products in a drop-down menu. The user will choose a product from each category, triggering an ajax call to retrieve the pric ...

Check if the string contains any numerical characters

Is there a way to check if a string contains at least one numerical character without verifying if the entire string is a number? The current code works in the following situations: If there is a single integer, such as "43", it will display the correspon ...

Exploring the World of ASP MVC and Jquery ajax Search

Recently, I created a code for an ajax search function that retrieves user information. In the Controller section: public JsonResult SearchPeopleByName1(string keyword) { System.Threading.Thread.Sleep(2000); ApplicationDbContext myDbConte ...

I can't understand why this question continues to linger, I just want to remove it

Is there a valid reason for this question to persist? I'm considering removing it. ...

Ways to eliminate the blue selection box when dragging canvas objects in fabric framework

I've been trying to find a solution to remove the annoying blue highlight box that appears when dragging on the canvas while using fabric js, but so far I haven't had any luck. I've tried the following code, but it only works for text and n ...

Flask template fails to render following a redirect

I have embarked on creating a simple CARTO application using a combination of Vue JS and Flask. If you wish to explore the entire code, it can be accessed from this github repository. Here's how the application is designed to function: The user m ...