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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:21:30+00:00 2026-06-14T17:21:30+00:00

I am using the following coding pattern: function submit() { function submitModalDone() { //

  • 0

I am using the following coding pattern:

function submit() {

    function submitModalDone() {
        // do something
    }

    function submitModalFail() {
        // do something
    }

    $.ajax(
       {
           url: "xxx"
       })
       .done(submitModalDone)
       .fail(submitModalFail);
}

I placed the submitModalDone and submitModalFail inside the submit function as these are only called from the $.ajax.

However is it a good idea to just add my code as is to the end of the function and after all of the child functions. Is there a design pattern that would be a better fit for this? It seems strange that the $.ajax code and other code just sits there outside any container.

  • 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-14T17:21:31+00:00Added an answer on June 14, 2026 at 5:21 pm

    I think that’s a decent, descriptive pattern.

    You might want to structure it like this, however:

    var submit = (function () {
    
        function submitModalDone() {
            // do something
        }
    
        function submitModalFail() {
            // do something
        }
    
        return function () {
            $.ajax({
                url: "xxx"
            }).done(submitModalDone).fail(submitModalFail);
        };
    
    }());
    

    This avoids creating submitModalDone and submitModalFail every time submit is called.

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

Sidebar

Related Questions

I am using following code to get bitmap from url. This function is used
In my application I'm using following coding pattern to vibrate my iPhone device Include:
I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
In my application I m using following coding convention to open my default screen
I am novice to jquery and asp.net. I am using the following coding to
I'm coding the following using VS2010, C#, ASP.NET: DateTime dt = DateTime.Parse(2012-03-11T02:53:58-08:00); //Date is
Coding for PHP on Mac OSX Lion, using the following within the httpd.conf file:
I am using the following code to convert contents in Editor(Ajax control) to pdf,
I am coding a PHP foreach loop. I am using the following code to
I am using the following coding <html> <head> <style> #thediv { margin:0 auto; height:400px;

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.