I have one button on clicking I need multiple things need to be done, so I went for AJAX and PHP:$('.go_nxt_lsn').live('click',function(e){    e.stopPropagation();    var user_id = $('input[name=user_id]').val();    var course_id = $('input[name=course_id]').val();    var taskName = SaveActivity;    var subTask = watchvideo;    var lesson_id = $(this).attr('data-lesson-id');    var video_id = $(this).attr('data-video-id');    var course_box = '.course_'+course_id;    var refresh_boo = 1;    $.ajax({        type        : 'POST',         url         : '<?php echo $vars['url']?>learn/pages/syllabus/saveitems.php',        datatype    : 'html',        data        : {subtask:subTask,lessonid:lesson_id,theSubModID:video_id,userid:user_id,prodid:course_id,taskname:taskName},        success:function(data)        {            taskName = GoToNextLesson            $.ajax({                type        : 'POST',                 url         : '<?php echo $vars['url']?>learn/pages/syllabus/saveitems.php',                datatype    : 'html',                data        : {subtask:subTask,lessonid:lesson_id,userid:user_id,prodid:course_id,taskname:taskName},                success:function(data)                {                       $.ajax({                        type        : 'POST',                         url         : '<?php echo $vars['url']?>learn/pages/syllabus/learn.php',                        datatype    : 'json',                        data        : {user_id:user_id,course_id:course_id},                        success:function(data)                        {                            $.ajax({                                type        : 'POST',                                 url         : '<?php echo $vars['url']?>mod/event_calendar/views/default/event_calendar/instantlearn.php',                                datatype    : 'html',                                data        : {learn_details:data,refresh_boo:refresh_boo,prodid:course_id},                                success:function(data)                                {                                    $(course_box).replaceWith(data);                                    $(.accordion).accordion({                                             active: false,                                         collapsible: true,                                        heightStyle: content                                   });                                }                            });                        }                    });                }            });        }    });});I am sending four AJAX requests one by one, so I want an alternate for this. This code works fine. But this is so lengthy. Can anybody suggest how I can minimize it?
Alternate for nested Ajax requests
javascript;php;jquery;ajax