How to lay out the function in the ajax request?

Place to the function success: function(response) { can't understand why it is not running
AJAX JS
$('#cab_doc').on('click',function () {
$.ajax({
 type: 'POST',
 url: 'ajax.php',
 data: {
 cab_doc: true
},
 success: function(response) { 
$('#contents').html(
response
);
$('#help_active,#api_doc_active').removeClass('dx-nav-active');
$('#cab_doc_active').addClass('dx-nav-active');
}
});
$.ajax({
 type: 'POST',
 url: 'ajax.php',
 data: {
 interaction_cab_doc: true
},
 success: function(response) { 
$('#interaction').html(
response
);
 navMenuAPI(); // Menu with buttons for languages
 mobileNavMenu(); // Side menu
 sideMenuScript(); // Side menu 
 colorNav(); 
}
});
 });


Blocks with marking of the body
AJAX PHP
$myCurl = curl_init();
 curl_setopt_array($myCurl, array(
 CURLOPT_URL => 'http://192.168.2.245/',
 CURLOPT_RETURNTRANSFER => true,
));
 $response = curl_exec($myCurl);
 $data = $_POST;

/*==============================================================================*/
 // Menu 
 if ($data['interaction_api_doc'] == true){
 require_once"menu/header_wrapper.php"; 
require_once"menu/nav_menu-api_doc.php";
require_once"menu/nav_menu_mobile-api_doc.php";
 echo '
 <div id="background">
 <div class="background-actual"></div>
</div>
';
}

 if ($data['interaction_cab_doc'] == true){
require_once"menu/nav_menu-cab_doc.php";
require_once"menu/nav_menu_mobile-cab_doc.php";
}

 if ($data['interaction_help'] == true){
}
 /*==============================================================================*/



The script is 100% working if you put a line in index file
script JS
colorNav function() {
 // Highlighting of text when scrolling
 $(window).on("load",function(){ 
 $("#documenter_nav a").mPageScroll2id({
layout:"auto",
offset:10,
 highlightSelector:"#documenter_nav a"
 }); 
});
}



Here is the markup which needs to highlighted text when you click on anchors and scale
HTML
<div id="documenter_sidebar">
 <div id="scrollholder" class="scrollholder">
 <div id="scroll" class="scroll">
 <ol id="documenter_nav">

 the <li><a class="nav-link" href="#documenter-1"><i class="far fa-check-circle"></i> name</a></li>
 the <li><a class="nav-link" href="#documenter-2"><i class="far fa-comment-dots"></i> name</a></li> 
 the <li><a class="nav-link" href="#documenter-3"><i class="fa fas-clipboard-check"></i> name</a></li>
 the <li><a class="nav-link" href="#documenter-4"><i class="fa fas-file-invoice-dollar"></i> name</a></li>

the <li>
 <a class="nav-link" href="#documenter-5"><i class="fa fas-sms"></i> name</a>
 the <li><a class="nav-link ml-3 my-1" href="#documenter-5-1"> name</a></li>
 the <li><a class="nav-link ml-3 my-1" href="#documenter-5-1-1"> name</a></li>

 the <li><a class="nav-link ml-3 my-1" href="#documenter-5-2"> name</a></li>
 the <li><a class="nav-link ml-3 my-1" href="#documenter-5-2-1"> name</a></li>
</li>

</ol>
</div>
</div>
</div>


Should work as here in this demo manos.malihu.gr/repository/page-scroll-to-id/demo/... but the script is placed in the AJAX is not executed(( Please help, what does the "nail"?(
March 19th 20 at 08:52
1 answer
March 19th 20 at 08:54
Of course, I could be wrong, but I think that AJAX the JS should look like this
$('#cab_doc').on('click',function () {
$.ajax({
 type: 'POST',
 url: 'ajax.php',
 data: {
 cab_doc: true
},
 success: function(response) { 
$('#contents').html(
response
);
$('#help_active,#api_doc_active').removeClass('dx-nav-active');
$('#cab_doc_active').addClass('dx-nav-active');

$.ajax({
 type: 'POST',
 url: 'ajax.php',
 data: {
 interaction_cab_doc: true
},
 success: function(response) { 
$('#interaction').html(
response
);
 navMenuAPI(); // Menu with buttons for languages
 mobileNavMenu(); // Side menu
 sideMenuScript(); // Side menu 
 colorNav(); 
}
});
}
 }); 
 });
@rigoberto.Parisian, I just cut the code from the script, it works and functions navMenuAPI(); mobileNavMenu(); sideMenuScript(); are not running the latest only - Sabina.Upton commented on March 19th 20 at 08:57

Find more questions by tags JavaScriptAJAX