Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:58:30+00:00 2026-06-11T09:58:30+00:00

When I add category in controller action I return JSON object: return Json(new {

  • 0

When I add category in controller action I return JSON object:

return Json(new { categoryName = category.Name, isPrimary = isPrim ? "1" : "-1", categoryId = categoryId }, JsonRequestBehavior.AllowGet);

In JS handler function I add item on page:

...
var totalLink = "<li style='color: #bbbbbb;'>" + result.categoryName + "<a class='removeCategoryButton' href='#lnk#'>remove</a></li>";

                            var lnk = '@Url.Action("RemoveCategoryFromLocation", "Location", new{locationId = Model.Location.TicketId,  categoryId=-1})';

                            totalLink = totalLink.replace('#lnk#', lnk);
                            totalLink = totalLink.replace('-1', result.categoryId);

                            $('#otherCategories').append(totalLink);
...

When I click on remove link I call the following function:

$(function () {
            $('.removeCategoryButton').click(function (event) {
                event.preventDefault();
                $.ajax({
                    url: this.href,
                    type: 'POST',
                    context: this,
                    success: function (result) {
                        if(result.categoryName == 1) {
                            $(this).closest('li').remove();
                        }
                    }
                });
                return false;
            });
        });

But I get the following error:

This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.

This error happens only when I add item and want to remove it as soon after add on page. If I refresh page and click on remove link it works without problem.
Just to note when I get the error from above category is removed, so call works it just from some reason pop this error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:58:31+00:00Added an answer on June 11, 2026 at 9:58 am

    You seem to be adding the remove links dynamically and yet you have subscribed to the .click event handler only once when the DOM is ready. So make sure you do it in a lively manner. But since the .live() method is deprecated, depending on the jQuery version that you are using you should use either .delegate() or the .on() methods.

    So with the latest version of jQuery it is recommended to use .on():

    $(document).on(events, selector, data, handler);

    $(document).on('click', '.removeCategoryButton', function () {
        $.ajax({
            url: this.href,
            type: 'POST',
            context: this,
            success: function (result) {
                if(result.categoryName == 1) {
                    $(this).closest('li').remove();
                }
            }
        });
        return false;
    });
    

    Notice that you no longer need to wrap this in a document.ready callback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

routes .Add (Detail, new Route ({maincategory}/{category}, new RouteValueDictionary (new { controller = Category, action
Here is my route: routes.MapRoute(null, myaccount/monitor/{category}, // Matches new { controller = MyAccount, action
new.html.erb <h3>Add post</h3> <%= form_tag :controller=>'posts', :action=>'create' do %> <%= label :q, :Title %>
shop.category: Reverse query name for field 'parent_category' clashes with related field 'Category.category'. Add a
I need to add a http://mysite/categoryname route, so i added routes.MapRoute( Categories, {CategoryName}, new
mysql> ALTER TABLE category ADD CONSTRAINT category_parent_category_id FOREIGN KEY (parent) REFERENCES category(id); ERROR 1005
In my Android: String cat_id = getIntent().getExtras().getString(category_id); ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair(cat_id,
I add webview and navigationbar inside my view controller . Web view is display
To add a new pair to Hash I do: {:a => 1, :b =>
Here is my situation: I have a controller action called OrderFromCategory which fills a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.