How can I use Ajax to open views in Asp.net Core 3.1?

Why is the view not being displayed even though there is no error?

jQuery :

  $('#edit_button').on("click", function () {
        var instance = $('#jstree').jstree("get_selected");
      
        if (instance != 0) {
            $.getJSON("/AdminPanel/Category/EditMainCategory/" + instance);
        } else {
            swal("choose category");
            return false;
        }

    });

Controller :

 public IActionResult EditMainCategory(Guid Id)
    {
        var maincategory = _admin.GetCategoryById(Id);
        return View(maincategory);
    }

Answer №1

Give this a shot

if(instance !== 0)
{
 window.location.href = '/AdminPanel/Category/EditMainCategory' + instance;
}

It is presumed that 'instance' corresponds to your id parameter within the EditMainCategory function.

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

Display function not functioning properly following AJAX request

I'm working on a functionality where I want to initially hide a table when the page loads, and then display it with the results when a form is submitted using Ajax. The issue I'm facing is that the code refreshes the page and sets the table back ...

Having difficulty generating dynamic rows and tree dropdowns in AngularJS

Struggling to implement dynamic row functionality with Angular JS. The rows are working well, but I also need to incorporate a tree dropdown within each row. Unfortunately, clicking the "add row" button populates the same data in all rows. I have shared m ...

Inject an html <img> tag using an AJAX PHP call

Greetings everyone, I am currently in the process of developing a captcha maker using PHP with an Object-Oriented Programming (OOP) approach. The implementation involves a Captcha class responsible for generating the captcha image. You can find the complet ...

Guide to declaring variables using jQuery

Currently tackling a school project, I stumbled upon some online example solutions and managed to decipher most of the code. However, there is one line that has me puzzled. var $newTweet = $('<div class=tweet></div>'); My assumption ...

Implementing paginated query results using PHP and AJAX

I am working on a filter form in my website's HTML, which sends data to PHP via AJAX to execute a query. I want to implement pagination for the results retrieved from this query. What is the most effective way to achieve this? You can visit the site ...

Seeking specific parameter in a JSON array using JavaScript: A guide

Currently, I am working on a project that involves retrieving Facebook news feed data using the graph API. Upon receiving the JSON object, I display it on the page. The "Likes" section is presented as an array of JSON objects like this: data.likes: { ...

Wicket - Shifting items between different data views

Using Apache Wicket has presented me with a challenge... In my java class, named "task," I am managing both active and finished tasks. I have successfully implemented a sortable dataView for active tasks: Within this DataView implementation, each ta ...

Utilizing React Redux to handle nested AJAX requests

Currently, I am developing some demoware and have encountered a situation where I need to make two AJAX calls. The first call is to check the last modified date and determine whether data from the second call should be fetched or not. Although this metho ...

"Utilizing AJAX to set an array as a global variable

Struggling with storing data values from an AJAX response XML into a global array, and then attempting to call a function that removes specific elements from it. The issue lies in the fact that the array is not declared as global. Here's the current c ...

Adjust color scheme of drop-down menu

Having trouble changing the background color for my drop down menu. I tried to change the color for the sub div but it's not working. Can anyone help me fix this issue? Here is the code snippet: http://jsfiddle.net/3VBQ6/4/ #nav li:hover ul.sub li { ...

Navigating with Rails and Devise: How to send the user back to the original page after logging in successfully?

I have implemented the idiom described in this resource # /app/controllers/application_controller.rb class ApplicationController < ActionController::Base before_filter do |controller| redirect_to new_login_url unless controller.send(:logged_in?) ...

Shut down a pop-up overlay

I've been facing a challenge in implementing greasemonkey to automatically close a modal when the "x" button is clicked. Allow me to share with you the code snippet for the webpage: <div class="modal-header"> <button type="button" class="clo ...

Encountering 'Error 405 - Method not Supported' while making an Ajax POST request in ASP.NET Web API

I am currently in the process of developing a straightforward Web API service that captures input data from an HTML form, converts it into JSON format, and forwards it to a Web API. My coding platform is ASP.NET Web API on Visual Studio 2017. To further el ...

Customize each point in JQuery Flot with different colors and sizes

Is it possible to manipulate the attributes of individual points in a jquery flot plot? Adjusting the size of dots: My goal is to create a three-dimensional graph where the third dimension is represented by the size of the points. The larger the value, th ...

Transmit intricate json data through a concealed variable and retrieve it in an mvc 3 controller

I am looking to achieve the following task. Encode a complex JSON object and store it in a hidden input variable. Retrieve the hidden variable using the form collection object. Transform the hidden text value into a dynamic object for seamless data retri ...

Using ServiceStack to deserialize an array

My goal is to post the following data to my ServiceStack web service: $.ajax({ url: 'http://localhost:8092/profiles', type:'POST', data: { FirstName : "John", LastName : "Doe", Categories : [ "Catego ...

I encountered no response when attempting to trigger an alert using jQuery within the CodeIgniter framework

Jquery/Javascript seem to be causing issues in codeigniter. Here is what I have done so far: In my config.php file, I made the following additions: $config['javascript_location'] = 'libraries/javascript/jquery.js'; $config['javas ...

Utilize jQuery to choose a specific tab

I have implemented a jquery tab in my UI. I want to have the second tab selected when the page loads, instead of defaulting to the tab with the "Active" class. Here is my HTML tab code: <div class="typo"> <div class="container-fluid"> ...

Sending an array of objects in JavaScript to a controller

I have a dynamic form that I'm trying to submit to my Controller. Instead of sending just a string or an array with data, I need to pass an array of objects using ajax request after building the Javascript Array. The challenge is that when I send only ...

I'm puzzled as to why implementing jQuery UI autocomplete on my dropdowns is also affecting my listbox

I have been attempting to update my comboboxes to utilize autocomplete, so I found this code (which worked beautifully for my dropdown menus) The problem arises when I also have a listbox on the same page with the following code: <%= Html.ListBox("Car ...