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 8636795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:18:38+00:00 2026-06-12T10:18:38+00:00

I have some strange behaviour going on with the jQuery ajax functionality in my

  • 0

I have some strange behaviour going on with the jQuery ajax functionality in my asp.net MVC3 application.

I have several boxes of data each containing a link to open a popup and change the data in each box. To do this I’ve added a jquery live() click event to process the data via a jQuery ajax call. In the “success” method of the ajax call, i take the return data and open a UI Dialog popup (a partial view) which contains a list of radio buttons. I select a different radio button and press ‘close’ – the close button fires another live() click event, processes that new data via an ajax call which refreshes the data in the box on the main page.

This works perfectly first time. If you then click to change it again, the popup opens, allows you to select a new value, but this time pressing close on the popup triggers two click events which throws an null error in my MVC controller.

If you repeat this process it triggers 3 click events, so it’s clear that live() is appending these events somewhere.

I’ve tried using on() and click(), but the page itself is made up of panels loaded in via ajax so I used live() to automatically bind the events.

Here is the code I’m using:

HTML

<p><!--Data to update goes here--></p>
<a href="#" class="adjust">Update Data</a>

First Click event calling popup with Partial View

$('a.adjust').live('click', function (e) { 
    var jsonData = getJsonString(n[1]);
    var url = '@Url.Action("ChangeOptions", "Search")';
    var dialog = $('<div id="ModalDialog" style="display:none"></div>').appendTo('body');
    // load the data via ajax
    $.ajax({
        url: url,
        type: 'POST',
        cache: false,
        contentType: "application/json; charset=utf-8",
        data: jsonData,
        success: function (response) {
            dialog.html(response);
            dialog.dialog({
                bgiframe: true,
                modal: true
                }
            });
        }
    });
    e.preventDefault();
});

Second click event the takes the new info to return updated partial view

$('a#close').live('click', function (event) { 
    var jsonData = getJsonString(n[1]);
    var url = '@Url.Action("GetChangeInfo", "Search")';
    $.ajax({
        url: url,
        type: 'POST',
        contentType: "application/json; charset=utf-8",
        data: jsonData,
        success: function (response) {
            $('#box-' + @column).html(response);  //this refreshes the box on the main page
        },
        error: function () {
        }
    });
    $('#ModalDialog').dialog('close');
    event.preventDefault();
});

Anybody know what might be happening here, and how I could resolve it?

  • 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-12T10:18:40+00:00Added an answer on June 12, 2026 at 10:18 am

    Use namespaces to unbind previous click binds like this:

    $('a.adjust').unbind('click.adjustclick');
    

    Then bind the click action to a.adjust:

    $('a.adjust').bind('click.adjustclick', function(){
    
      //your code here
    
      //note the return false, this prevents the browser from visiting the URL in the href attribute
      return false;
    });
    

    If i understand you correctly, you try to run the second click action when the dialog is closed. Therefor I would use the build in close function for the dialog like this:

    $('a.adjust').bind('click.adjustclick', function(){
        var jsonData = getJsonString(n[1]);
        var url = '@Url.Action("ChangeOptions", "Search")';
        var dialog = $('<div id="ModalDialog" style="display:none"></div>').appendTo('body');
        // load the data via ajax
    
        $.ajax({
            url: url,
            type: 'POST',
            cache: false,
            contentType: "application/json; charset=utf-8",
            data: jsonData,
            success: function (response) {
                dialog.html(response);
                dialog.dialog({
                    bgiframe: true,
                    modal: true,
                    close: function(){
                        var jsonData2 = getJsonString(n[1]);
                        var url2 = '@Url.Action("GetChangeInfo", "Search")';
    
                        $.ajax({
                            url: url2,
                            type: 'POST',
                            contentType: "application/json; charset=utf-8",
                            data: jsonData2,
                            success: function (response2) {
                                $('#box-' + @column).html(response2);  //this refreshes the box on the main page
                            },
                            error: function () {
                            }
                        });
                      }
                    }
                });
            }
        });
    });
    

    If you are using your own button a#close, bind a click event to it to close the dialog, it will automatically fire the close function for the dialog.

    $('a#close').unbind('click.closedialog');
    $('a#close').bind('click.closedialog', function () {
      $('#ModalDialog').dialog('close');
      return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have some strange behaviour regarding output caching in an ASP.NET 4 application on IIS
after adding adMob ads to my application, I have noticed some strange memory behaviour.
I'm working on a WebCenter Spaces application and have observed some strange behaviour in
I'm hacking my way through learning Flex and have found some strange behaviour. When
I have come across some strange behaviour, and I'm assuming a bug in Firefox,
I have some strange comportement with my ajax request. The ajax request processes correctly,
I have some strange scrolling problems with my PhoneGap (using jQuery Mobile) app: I'm
I'm trying to learn python and have encountered some strange behaviour. I am experimenting
I have a strange behaviour going on. I am using Seam and JBPM. When
We have some strange behaviour with the deployment of our message queues and factories

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.