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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:22:25+00:00 2026-05-30T05:22:25+00:00

In a web app I am developing I display a Modal dialog using Bootstrap.

  • 0

In a web app I am developing I display a Modal dialog using Bootstrap. Within that dialog I have form elements and a save button. When the user clicks save I fire a function which calls $.post to invoke an asp.net mvc action to save the data entered.

The browser (Chrome) displays the following message when I click the Save button:

“Something Unexpected Happened :(…..” .

After confirming the error message the asp.net action is invoked and the rest of the script completes fine. I also see the same error if I use $.ajax.

IE gives slightly different behaviour. Isee the same message in IE but it appears after the success callback function completes.

If I call the save function from outside the modal dialog I do not see this error message.

function saveUser() {
    var userId = $('#userId').val();
    var fullName = $('#fullName').val();
    var userName = $('#userName').val();
    var isAdmin =  $('#isAdmin').is(':checked');
    var authenticationMode =  $('#userAuthenticationMode').val();

    $.post(
        "@Url.Action("Save", "Account")",
        {
            userId :  userId,
            fullName : fullName,
            userName : userName,
            isAdmin : isAdmin,
            authenticationMode : authenticationMode
        }, 
        function (data) {
            if (data.Success) {
                alert("success");
            }
            else {
                alert("failed");
            }
        }
    );

Here is the modal declaration:

<div id="update_user_modal" class="modal hide">
      . 
      .
      .    
    <div  style="float:right">
        <button id="SaveUser" class="btn btn-primary">Save changes</button>
    </div>
</div>

Update:

Found the source of the alert message. There’s an ajax error handler in the code which a colleague failed to mention:

// Set up AJAX error handling ...
$(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
if (jqXHR.status == 404) {
    $("#NotFoundInfoDialog").dialog("open");
} else if (jqXHR.status == 500) {
    $("#InternalServerErrorDialog").dialog("open");
} else {
    alert("Something unexpected happend :( ...");
  }
});

Any ideas on how I can debug the ajax error. jqXHR.status returns 0.

Update
When I use $.ajax to make an ajax call the following occurs:
First time I attempt to save an unknown ajax exception is raised and the modal closes.
If I display the modal again and attempt to Save it works fine.
If I know try to display the modal again and save I get an ‘Internal Server error’. My mvc action is working fine.

Update
Have no idea why but removing the form tags in the modal div solved the problem.

Thanks,

Lance

  • 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-05-30T05:22:26+00:00Added an answer on May 30, 2026 at 5:22 am

    you have bind ajaxError in wrong way, if status is not 404 or 500 then it always go to else block which display the error “something unexpected happend”, so change it

    $(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
    if (jqXHR.status != 200){
     if (jqXHR.status == 404) {
         $("#NotFoundInfoDialog").dialog("open");
     } else if (jqXHR.status == 500) {
         $("#InternalServerErrorDialog").dialog("open");
     } else{
         alert("Something unexpected happend :( ...");
       }
     }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web app (using rails) that I will be launching within
I'm developing web app that user can save his/her work to server. The data
I am developing a web app using servlets and jsps. I have a question
I have a web app I'm developing and quite like the idea that if
I am developing web app using Scala and Lift framework. I have record in
I'm developing a web app and currently using sql server 2008 for it. But,
I'm developing an offline web app that (for now) only targets Safari on the
I am using struts2 for developing a web application. I have include the required
I am developing an application on the Google App Engine using Python. I have
I am trying to debug my web app and i have realised that firebug

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.