JavaScript how to trigger animatedmodal window after success ajax call?

How to open the modal after a ajax call on success i need to trigger the modal window automatically

<a class="main_blue_button" target='_blank' href="#complete_application_modal" id="applicationBtn">SIGN UP</a>

<div id="complete_application_modal">adsfadsf</div>

how to open the modal after on success ajax call

    $.ajax({
type: "POST",
url: "<?php echo site_url(); ?>users/signUp_business",
data: $('#signup_form').serialize(),   
dataType: "json",
success: function(result){
//alert(result);
    if(result.error==0){
        $("#show_error").html("This email or phone is already registered!");
        //$("#business_email").focus(); 
            $("#busp_email").removeClass('field_validation_error hidden');
                $("#busp_email").addClass('field_validation_error');
                $("#bus_email").css("color","#f42156");
                hasError = true;
    }else if(result.success==1) {

    $("#signup_form")[0].reset();

    $("#applicationBtn").attr("href","#complete_application_modal");

    //$("#applicationBtn").attr("href", "#complete_application_modal").trigger('click');
        $("a").trigger("click");

    }
Answer:1

I think if your primary goal is to display modal window on ajax success you can simply do it by

$('#complete_application_modal').show();

and can hide it by

$('#complete_application_modal').show();

Then why are you using link reference..?

Answer:2

here is the modification to allow this

    (function ($) {

    $.fn.animatedModal = function(options) {
        var modal = $(this);

        //Defaults
        var settings = $.extend({
            modalTarget:'animatedModal', 
            position:'fixed', 
            width:'100%', 
            height:'100%', 
            top:'0px', 
            left:'0px', 
            zIndexIn: '9999',  
            zIndexOut: '-9999',  
            color: '#39BEB9', 
            opacityIn:'1',  
            opacityOut:'0', 
            animatedIn:'zoomIn',
            animatedOut:'zoomOut',
            animationDuration:'.6s', 
            overflow:'auto', 
            // Callbacks
            beforeOpen: function() {},           
            afterOpen: function() {}, 
            beforeClose: function() {}, 
            afterClose: function() {},
            override: false
        }, options);

        var closeBt = $('.close-'+settings.modalTarget);

        //console.log(closeBt)

        var href = $(modal).attr('href'),
            id = $('body').find('#'+settings.modalTarget),
            idConc = '#'+id.attr('id');
            //console.log(idConc);
            // Default Classes
            id.addClass('animated');
            id.addClass(settings.modalTarget+'-off');

        //Init styles
        var initStyles = {
            'position':settings.position,
            'width':settings.width,
            'height':settings.height,
            'top':settings.top,
            'left':settings.left,
            'background-color':settings.color,
            'overflow-y':settings.overflow,
            'z-index':settings.zIndexOut,
            'opacity':settings.opacityOut,
            '-webkit-animation-duration':settings.animationDuration
        };
        //Apply stles
        id.css(initStyles);

        if (!settings.override) {
            modal.click(function(event) {
                event.preventDefault();
                open();
            });
        }

        closeBt.click(function(event) {
            event.preventDefault();
            $('body, html').css({'overflow':'auto'});

            settings.beforeClose(); //beforeClose
            if (id.hasClass(settings.modalTarget+'-on')) {
                id.removeClass(settings.modalTarget+'-on');
                id.addClass(settings.modalTarget+'-off');
            } 

            if (id.hasClass(settings.modalTarget+'-off')) {
                id.removeClass(settings.animatedIn);
                id.addClass(settings.animatedOut);
                id.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterClose);
            };

        });

        function afterClose () {       
            id.css({'z-index':settings.zIndexOut});
            settings.afterClose(); //afterClose
        }

        function afterOpen () {       
            settings.afterOpen(); //afterOpen
        }

        function open() {
            $('body, html').css({'overflow':'hidden'});
            if (href == idConc) {
                if (id.hasClass(settings.modalTarget+'-off')) {
                    id.removeClass(settings.animatedOut);
                    id.removeClass(settings.modalTarget+'-off');
                    id.addClass(settings.modalTarget+'-on');
                }

                if (id.hasClass(settings.modalTarget+'-on')) {
                    settings.beforeOpen();
                    id.css({'opacity':settings.opacityIn,'z-index':settings.zIndexIn});
                    id.addClass(settings.animatedIn);
                    id.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterOpen);
                };
            }
        }

        return {
            open: open
        };
    }; 
}(jQuery));

AND YOU CAN TRIGGER using

var service = $("#demo01").animatedModal({
    override: true
});
service.open();
Answer:3

one of the options in animatedModal is beforeOpen, you can use this option to call ajax request. like this:

$("#modal-btn").animatedModal({
  modalTarget:'animatedModal',
  beforeOpen: function() {
    // ajax request call here
    // fill modal by data
  }
});
Answer:4

I am facing issue while making a dynamic table with dynamic rowspan. My json is a array of objects. And the element objects are also arrays. The element arrays should come as the no of dynamic rowspan....

I am facing issue while making a dynamic table with dynamic rowspan. My json is a array of objects. And the element objects are also arrays. The element arrays should come as the no of dynamic rowspan....

  1. angularjs repeat start end
  2. angularjs repeat start
  3. angularjs ng-repeat-start
  4. angularjs ng-repeat start from index
  5. angularjs ng-repeat start end
  6. angularjs ng-repeat-start example
  7. angularjs ng-repeat-start filter
  8. angularjs ng-repeat-start nested
  9. angularjs ng-repeat-start table
  10. angularjs data-ng-repeat-start

I have to display the content in a grid. All items are div's with random height, and I need to have control over how they are displayed. It is a responsive UI with 4-cols, 3-cols and 1-cols. Assume ...

I have to display the content in a grid. All items are div's with random height, and I need to have control over how they are displayed. It is a responsive UI with 4-cols, 3-cols and 1-cols. Assume ...

  1. position div at bottom of parent
  2. position div in center
  3. position div at bottom of page
  4. position div relative to another div
  5. position div on top of another
  6. position div below another div
  7. position divided by time
  8. position divs side by side
  9. position div to right
  10. position div relative to parent
  11. position div in center of screen
  12. position div in center of parent
  13. position div bottom right of parent
  14. position div at bottom of screen
  15. position div inside div
  16. position div over image
  17. position div at top of page
  18. position div vertically center
  19. position div to right of another div
  20. position div at bottom of div

There are null and undefined in JavaScript. Are there any meaningful use cases of assigning undefined to a variable?

There are null and undefined in JavaScript. Are there any meaningful use cases of assigning undefined to a variable?

Input: seconds, Output: grammatically correct, formatted time (with words spelled out). So far I managed to get as far as going from say 40044373 to 1 year, 98 days, 5 hours, 37 minutes, 1 second - ...

Input: seconds, Output: grammatically correct, formatted time (with words spelled out). So far I managed to get as far as going from say 40044373 to 1 year, 98 days, 5 hours, 37 minutes, 1 second - ...

  1. commas right now