Transfer of table data from view to controller encountering issues

I am attempting to send the information from my dynamically populated table to the controller.

<tbody>
                                  @if (ViewBag.data != null)
                                  {
                                      foreach (var item in ViewBag.data)
                                      {
                                          <tr>
                                              <td class="AutoId">@item.AutoID <input type="hidden" name="AutoID" value="@item.AutoID" /></td>
                                              <td class="hove" name="text"><a href="#"> <b>@item.Text</b></a><br /><label></label></td>
                                              <td class="Active">@item.Active</td>
                                              
                                              <td id="oBy" name="OrderBy">@item.OrderBy</td>

                                          </tr>

                                      }
                                  }

This is the layout of the table.

For transferring a single field, I am implementing an ajax call as shown below...

<script>

    $(document).ready(function () {
        alert("Test 1");
        $("#btnSave").click(function (e) {
            alert("Test 2");
             $.ajax({
                 type: "POST",
                 url: '@Url.Action("LookupManagementUpdate", "Admin", new { Area = "Admin" })',
                 data: $(".hove").val(),

                 dataType: 'json',
                 async: false,

                 success: function (response) {

                     Success = true;




                 },
                 error: function (response) {


                 },

             });
                });
        });
</script>

Here is the code snippet for my controller:

 public string LookupManagementUpdate(string text)
        {


            return "answer"+Request["text"]+text;
        }

I have tried fetching the data using both Request and parameter methods, but it does not display the table data. This project is based on C#, MVC, and ADO.NET.

Answer №1

Consider using Ajax.BeginForm along with ajaxOptions for a successful implementation

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

Bootstrap 4 Alert: The collapse feature is currently in transition

Is there anyone out there who can assist me with solving a transition issue in Bootstrap 4? I am encountering the error message "Uncaught Error: Collapse is transitioning" when I don't include the bootstrap CSS. Unfortunately, including the bootstrap ...

The returned error object from express does not include the error message

I recently posted a question related to an error issue. I am now wondering if I should have edited that question instead. Regarding the code snippet below: app.use((err, req, res, next) => { res.status(err.status || 500); res.json({ message: e ...

Display a spinner while Angular is in the process of linking components

My current situation involves a view that takes around 3 seconds to render. During this time, users are left waiting with no indication of progress on the page. I attempted to implement a spinner for visual feedback, but unfortunately, it remains stuck and ...

"Utilizing Jquery for interactive menu functionality - delivering the requested JSON

I have successfully implemented a dynamic menu using jQuery that parses a JSON response file to create the menu. However, instead of having the menu items link to URLs, I want them to retrieve and parse JSON data from those URLs. Despite my efforts, the me ...

How can you handle a JSON field that is missing during deserialization and set it as

I came across a JSON structure that I need to deserialize, which is as follows: { "a": "foo", "b": { "c": "bar" } } However, sometimes the b field is not present, like this: { "a": "foo" } Below is the class I am using for deser ...

Retrieving model data using jQuery

This particular section displays a model property alongside a submit button. @Html.LabelFor(m => m.Password) @Html.PasswordFor(m => m.Password, new { id = "txtLgnPasswordReset", @class = "form-control avoid-copy-paste" }) <div class="row vert-of ...

Is it possible to dynamically change the formatting of certain parts of text within a textblock to appear

As an example, I would like a collection of text blocks bound to an Observable Collection to appear as follows: ABC BCF BOY BOOK ABSORB BEFORE ...

Is it possible to load a webpage in a WebBrowser control without displaying certain HTML elements by their IDs

Is there a way to load a specific page using the WebBrowser control without displaying unwanted advertisement banners in the 'tb' DIV element? I've searched online and came across an example that uses the mshtml reference, but I can't ...

Retrieve all exports from a module within a single file using Typescript/Javascript ES6 through programmatic means

I aim to extract the types of all module exports by iterating through them. I believe that this information should be accessible during compile time export const a = 123; export const b = 321; // Is there a way to achieve something similar in TypeScript/ ...

Guide on sending the API key to an API gateway through a request header with Jquery AJAX

I am facing an issue posting JSON data to an AWS API gateway that is protected by an API key. I managed to make the POST request successfully using Postman by adding the x-api-key header. However, I am struggling to achieve the same with JQuery code. How c ...

Vercel enables faster PAAPI transactions through Edge Caching

When working on a Nextjs site hosted on Vercel and making a call to Amazon's paapi, it's important to keep in mind the limitations imposed by Amazon on the number of transactions allowed per second and per day. The approach I'm taking involv ...

How can I send a Vue.js object to a Laravel controller?

I am working with a Vue component that includes an object like this - dataObj = [{id:1,name:'sanaulla'},{id:1,name:'parvez'}] When I try to send a post request to the Laravel Controller using the following code - axios.post("/api/ ...

Executing shell commands using an ajax call does not function properly on Linux systems

I have encountered an issue with my PHP script that utilizes shell_exec to execute a shell script. I am making an AJAX call to the PHP script. Interestingly, the script runs smoothly on Mac OS without any problems. However, when attempting to run it in my ...

jQuery class toggle malfunction

I have a series of list items with specific behavior when clicked: Clicking a list item will select it and add the class .selected If another list item is clicked, the previously selected item becomes unselected while the new one becomes selected If a se ...

What is the best way to implement setState in this scenario?

Receiving warnings in the console that say: Avoid changing state directly. Instead, use setState() method: react/no-direct-mutation-state When I tried changing this.state.turn = this.state.turn === 'X' ? 'O' : 'X'; to this.s ...

Tips for resolving the problem with a malfunctioning ChartJS legend

I have been working on my project using chartjs and all the charts are displaying correctly except for the legends. No matter what I try, the legend is not showing up. Here's the code snippet: var ctx1 = document.getElementById("chart1").getContext(" ...

The PHP response from the ajax call is not defined

My goal is to generate a PDF file using TCPDF through ajax. The process works flawlessly, the PDF is successfully saved on the server and I pass the URL to my HTML page. $responseArray = array('id' => 'Success', 'message1' ...

Troubleshooting: Unable to delete data using $http in AngularJS

When using the $http service in Angular JS to call an API for deleting a message, I am receiving a successful response but the value is not actually being deleted. Interestingly, when I directly access the same API in my browser, the message gets deleted s ...

Encountering an issue with the removal of slides when updating JSON data for angular-flexslider

Issue: Although my JSON object is updating, the slider does not update for all resorts as expected. Sometimes it fails to update when the JSON object changes. The resorts (image collections) that do not update are throwing an error stating "cannot read pr ...

Having trouble importing JS into HTML file with NodeJS

I have created a web server using NodeJS that serves the file index.html. However, when I attempt to add a JavaScript file to my HTML document, the browser displays an error message stating The resource "http://localhost:3000/includes/main.js" was blocked ...