Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Course Queries Syllabus Queries 2 years ago
Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
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 : '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 : '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 : 'url']?>learn/pages/syllabus/learn.php', datatype : 'json', data : {user_id:user_id,course_id:course_id}, success:function(data) { $.ajax({ type : 'POST', url : 'url']?>mod/event_calendar/views/default/event_calendar/instantlearn.php', REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
The chain of Ajax calls can be set programmatically, instead of being "hardcoded" as in your code. The next snippet shows a possible approach.
However, as Piotr pointed out, you should study your application a bit more to determine whether that is a good solution.
// First generate an array with all the ajax calls than need to be done, in order. var ajaxCalls = [ // First ajax function(){ return $.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} }); }, // Second ajax function(data){ return $.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} }); }, ... // Last function doesn't need to return a promise function(data){ $(course_box).replaceWith(data); $(".accordion").accordion({ active: false, collapsible: true, heightStyle: "content" }); } ]; // Every time you run an ajax, you want to set it up so that the next // ajax will be called as a response. Let's do a function for that: function callAjax(var index){ var thisAjax = ajaxCalls[index]; // Run the ajax var promise = thisAjax(); // Set up next one if necessary. var isLastAjax = (index === (ajaxCalls.length - 1)); if(!isLastAjax){ promise.done(function(){ callAjax(index + 1); }); } } // Call the first one callAjax(0);
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Course Queries 4 Answers
Course Queries 5 Answers
Course Queries 1 Answers
Course Queries 3 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.