I could not reload in single-click external div-contents that were inserted in main-page using Language...












0















I could not reload in single-click external div-contents that were inserted in main-page using Language-selector through jquery.



The links must be explicitly clicked in order jquery to change the "language" of the div-inserted external content to the right one.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



The actual url is here:



For example:



(a) Clicking "Services --> Contact",



(b) Then change the language,



(c) Content is not "reloaded" with the corresponding changed language content



I do not know how to perform that cause of the multiple links.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Note that the main page has multiple areas that are externally div-inserted e.g. main body and left side.



My guess: I would like something like this:



a) left_link_index--> "Detect current url",
load the content when language change



b) mainbody --> "Detect current url before hash"
load the content when language change



 $(document).ready(function() {
$("#mainbody").load(url_web)
$("#left_link_index").load(left_url_web)
});


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The script that is changing the language, as well loading external div-content



<script>
// stackoverflow: 49637061 & 11134701
$('[lang="en"]').show();
$('[lang="gr"]').hide();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_web)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_web)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_web)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_web)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_web)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_web)
});
$(document).on('click', '#id_contact_en', function(){
$("#mainbody").load("Services.html #contact_en").data('url_contact_en', "Services.html#contact_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_en');
$("#mainbody_2").html(url_web)
});
});

$('#lang_switch').change(function () {
var lang = $(this).val();
switch (lang) {
case 'gr':
$('[lang="en"]').hide();
$('[lang="gr"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
$("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_web)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
$("#left_link_index").load("Statistics.html #left_links_gr")
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_web)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_web)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_web)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
$("#left_link_index").load("Services.html #left_links_gr");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_web)
});
$(document).on('click', '#id_bio_history_gr', function(){
$("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
$("#mainbody_2").html(url_web)
});
$(document).on('click', '#id_info_gr', function(){
$("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
$("#mainbody_2").html(url_web)
});
$(document).on('click', '#id_contact_gr', function(){
$("#mainbody").load("Services.html #contact_gr").data('url_contact_gr', "Services.html#contact_gr");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_gr');
$("#mainbody_2").html(url_web)
});
});
break;
case 'en':
$('[lang="gr"]').hide();
$('[lang="en"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_web)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_web)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_web)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_web)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_web)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_web)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_web)
});
$(document).on('click', '#id_contact_en', function(){
$("#mainbody").load("Services.html #contact_en").data('url_contact_en', "Services.html#contact_en");
var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_en');
$("#mainbody_2").html(url_web)
});
});
break;
};
});
</script>









share|improve this question



























    0















    I could not reload in single-click external div-contents that were inserted in main-page using Language-selector through jquery.



    The links must be explicitly clicked in order jquery to change the "language" of the div-inserted external content to the right one.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



    The actual url is here:



    For example:



    (a) Clicking "Services --> Contact",



    (b) Then change the language,



    (c) Content is not "reloaded" with the corresponding changed language content



    I do not know how to perform that cause of the multiple links.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



    Note that the main page has multiple areas that are externally div-inserted e.g. main body and left side.



    My guess: I would like something like this:



    a) left_link_index--> "Detect current url",
    load the content when language change



    b) mainbody --> "Detect current url before hash"
    load the content when language change



     $(document).ready(function() {
    $("#mainbody").load(url_web)
    $("#left_link_index").load(left_url_web)
    });


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The script that is changing the language, as well loading external div-content



    <script>
    // stackoverflow: 49637061 & 11134701
    $('[lang="en"]').show();
    $('[lang="gr"]').hide();
    $(document).ready(function(){
    $("#idR_Code_PSPP").click(function(){
    $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
    $("#left_link_index").load("R_Code_PSPP.html #left_links_en")
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
    $("#mainbody_2").html(url_web)
    });
    $("#idStatistics").click(function(){
    $("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
    $("#left_link_index").load("Statistics.html #left_links_en")
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
    $("#mainbody_2").html(url_web)
    });
    $("#idStat_Article").click(function(){
    $("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
    $("#mainbody_2").html(url_web)
    });
    $("#idPlanets_Health").click(function(){
    $("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
    $("#mainbody_2").html(url_web)
    });
    $("#idServices").click(function(){
    $("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
    $("#left_link_index").load("Services.html #left_links_en");
    var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
    $("#mainbody_2").html(url_idServices)
    });
    $(document).on('click', '#id_bio_history_en', function(){
    $("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
    $("#mainbody_2").html(url_web)
    });
    $(document).on('click', '#id_info_en', function(){
    $("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
    $("#mainbody_2").html(url_web)
    });
    $(document).on('click', '#id_contact_en', function(){
    $("#mainbody").load("Services.html #contact_en").data('url_contact_en', "Services.html#contact_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_en');
    $("#mainbody_2").html(url_web)
    });
    });

    $('#lang_switch').change(function () {
    var lang = $(this).val();
    switch (lang) {
    case 'gr':
    $('[lang="en"]').hide();
    $('[lang="gr"]').show();
    $(document).ready(function(){
    $("#idR_Code_PSPP").click(function(){
    $("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
    $("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
    $("#mainbody_2").html(url_web)
    });
    $("#idStatistics").click(function(){
    $("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
    $("#left_link_index").load("Statistics.html #left_links_gr")
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
    $("#mainbody_2").html(url_web)
    });
    $("#idStat_Article").click(function(){
    $("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
    $("#mainbody_2").html(url_web)
    });
    $("#idPlanets_Health").click(function(){
    $("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
    $("#mainbody_2").html(url_web)
    });
    $("#idServices").click(function(){
    $("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
    $("#left_link_index").load("Services.html #left_links_gr");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
    $("#mainbody_2").html(url_web)
    });
    $(document).on('click', '#id_bio_history_gr', function(){
    $("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
    $("#mainbody_2").html(url_web)
    });
    $(document).on('click', '#id_info_gr', function(){
    $("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
    $("#mainbody_2").html(url_web)
    });
    $(document).on('click', '#id_contact_gr', function(){
    $("#mainbody").load("Services.html #contact_gr").data('url_contact_gr', "Services.html#contact_gr");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_gr');
    $("#mainbody_2").html(url_web)
    });
    });
    break;
    case 'en':
    $('[lang="gr"]').hide();
    $('[lang="en"]').show();
    $(document).ready(function(){
    $("#idR_Code_PSPP").click(function(){
    $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
    $("#left_link_index").load("R_Code_PSPP.html #left_links_en")
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
    $("#mainbody_2").html(url_web)
    });
    $("#idStatistics").click(function(){
    $("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
    $("#left_link_index").load("Statistics.html #left_links_en")
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
    $("#mainbody_2").html(url_web)
    });
    $("#idStat_Article").click(function(){
    $("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
    $("#mainbody_2").html(url_web)
    });
    $("#idPlanets_Health").click(function(){
    $("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
    $("#mainbody_2").html(url_web)
    });
    $("#idServices").click(function(){
    $("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
    $("#left_link_index").load("Services.html #left_links_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
    $("#mainbody_2").html(url_web)
    });
    $(document).on('click', '#id_bio_history_en', function(){
    $("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
    $("#mainbody_2").html(url_web)
    });
    $(document).on('click', '#id_info_en', function(){
    $("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
    $("#mainbody_2").html(url_web)
    });
    $(document).on('click', '#id_contact_en', function(){
    $("#mainbody").load("Services.html #contact_en").data('url_contact_en', "Services.html#contact_en");
    var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_en');
    $("#mainbody_2").html(url_web)
    });
    });
    break;
    };
    });
    </script>









    share|improve this question

























      0












      0








      0








      I could not reload in single-click external div-contents that were inserted in main-page using Language-selector through jquery.



      The links must be explicitly clicked in order jquery to change the "language" of the div-inserted external content to the right one.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



      The actual url is here:



      For example:



      (a) Clicking "Services --> Contact",



      (b) Then change the language,



      (c) Content is not "reloaded" with the corresponding changed language content



      I do not know how to perform that cause of the multiple links.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



      Note that the main page has multiple areas that are externally div-inserted e.g. main body and left side.



      My guess: I would like something like this:



      a) left_link_index--> "Detect current url",
      load the content when language change



      b) mainbody --> "Detect current url before hash"
      load the content when language change



       $(document).ready(function() {
      $("#mainbody").load(url_web)
      $("#left_link_index").load(left_url_web)
      });


      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      The script that is changing the language, as well loading external div-content



      <script>
      // stackoverflow: 49637061 & 11134701
      $('[lang="en"]').show();
      $('[lang="gr"]').hide();
      $(document).ready(function(){
      $("#idR_Code_PSPP").click(function(){
      $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
      $("#left_link_index").load("R_Code_PSPP.html #left_links_en")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
      $("#mainbody_2").html(url_web)
      });
      $("#idStatistics").click(function(){
      $("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
      $("#left_link_index").load("Statistics.html #left_links_en")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
      $("#mainbody_2").html(url_web)
      });
      $("#idStat_Article").click(function(){
      $("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
      $("#mainbody_2").html(url_web)
      });
      $("#idPlanets_Health").click(function(){
      $("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
      $("#mainbody_2").html(url_web)
      });
      $("#idServices").click(function(){
      $("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
      $("#left_link_index").load("Services.html #left_links_en");
      var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
      $("#mainbody_2").html(url_idServices)
      });
      $(document).on('click', '#id_bio_history_en', function(){
      $("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_info_en', function(){
      $("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_contact_en', function(){
      $("#mainbody").load("Services.html #contact_en").data('url_contact_en', "Services.html#contact_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_en');
      $("#mainbody_2").html(url_web)
      });
      });

      $('#lang_switch').change(function () {
      var lang = $(this).val();
      switch (lang) {
      case 'gr':
      $('[lang="en"]').hide();
      $('[lang="gr"]').show();
      $(document).ready(function(){
      $("#idR_Code_PSPP").click(function(){
      $("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
      $("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
      $("#mainbody_2").html(url_web)
      });
      $("#idStatistics").click(function(){
      $("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
      $("#left_link_index").load("Statistics.html #left_links_gr")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
      $("#mainbody_2").html(url_web)
      });
      $("#idStat_Article").click(function(){
      $("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
      $("#mainbody_2").html(url_web)
      });
      $("#idPlanets_Health").click(function(){
      $("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
      $("#mainbody_2").html(url_web)
      });
      $("#idServices").click(function(){
      $("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
      $("#left_link_index").load("Services.html #left_links_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_bio_history_gr', function(){
      $("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_info_gr', function(){
      $("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_contact_gr', function(){
      $("#mainbody").load("Services.html #contact_gr").data('url_contact_gr', "Services.html#contact_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_gr');
      $("#mainbody_2").html(url_web)
      });
      });
      break;
      case 'en':
      $('[lang="gr"]').hide();
      $('[lang="en"]').show();
      $(document).ready(function(){
      $("#idR_Code_PSPP").click(function(){
      $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
      $("#left_link_index").load("R_Code_PSPP.html #left_links_en")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
      $("#mainbody_2").html(url_web)
      });
      $("#idStatistics").click(function(){
      $("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
      $("#left_link_index").load("Statistics.html #left_links_en")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
      $("#mainbody_2").html(url_web)
      });
      $("#idStat_Article").click(function(){
      $("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
      $("#mainbody_2").html(url_web)
      });
      $("#idPlanets_Health").click(function(){
      $("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
      $("#mainbody_2").html(url_web)
      });
      $("#idServices").click(function(){
      $("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
      $("#left_link_index").load("Services.html #left_links_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_bio_history_en', function(){
      $("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_info_en', function(){
      $("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_contact_en', function(){
      $("#mainbody").load("Services.html #contact_en").data('url_contact_en', "Services.html#contact_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_en');
      $("#mainbody_2").html(url_web)
      });
      });
      break;
      };
      });
      </script>









      share|improve this question














      I could not reload in single-click external div-contents that were inserted in main-page using Language-selector through jquery.



      The links must be explicitly clicked in order jquery to change the "language" of the div-inserted external content to the right one.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



      The actual url is here:



      For example:



      (a) Clicking "Services --> Contact",



      (b) Then change the language,



      (c) Content is not "reloaded" with the corresponding changed language content



      I do not know how to perform that cause of the multiple links.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



      Note that the main page has multiple areas that are externally div-inserted e.g. main body and left side.



      My guess: I would like something like this:



      a) left_link_index--> "Detect current url",
      load the content when language change



      b) mainbody --> "Detect current url before hash"
      load the content when language change



       $(document).ready(function() {
      $("#mainbody").load(url_web)
      $("#left_link_index").load(left_url_web)
      });


      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      The script that is changing the language, as well loading external div-content



      <script>
      // stackoverflow: 49637061 & 11134701
      $('[lang="en"]').show();
      $('[lang="gr"]').hide();
      $(document).ready(function(){
      $("#idR_Code_PSPP").click(function(){
      $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
      $("#left_link_index").load("R_Code_PSPP.html #left_links_en")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
      $("#mainbody_2").html(url_web)
      });
      $("#idStatistics").click(function(){
      $("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
      $("#left_link_index").load("Statistics.html #left_links_en")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
      $("#mainbody_2").html(url_web)
      });
      $("#idStat_Article").click(function(){
      $("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
      $("#mainbody_2").html(url_web)
      });
      $("#idPlanets_Health").click(function(){
      $("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
      $("#mainbody_2").html(url_web)
      });
      $("#idServices").click(function(){
      $("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
      $("#left_link_index").load("Services.html #left_links_en");
      var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
      $("#mainbody_2").html(url_idServices)
      });
      $(document).on('click', '#id_bio_history_en', function(){
      $("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_info_en', function(){
      $("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_contact_en', function(){
      $("#mainbody").load("Services.html #contact_en").data('url_contact_en', "Services.html#contact_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_en');
      $("#mainbody_2").html(url_web)
      });
      });

      $('#lang_switch').change(function () {
      var lang = $(this).val();
      switch (lang) {
      case 'gr':
      $('[lang="en"]').hide();
      $('[lang="gr"]').show();
      $(document).ready(function(){
      $("#idR_Code_PSPP").click(function(){
      $("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
      $("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
      $("#mainbody_2").html(url_web)
      });
      $("#idStatistics").click(function(){
      $("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
      $("#left_link_index").load("Statistics.html #left_links_gr")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
      $("#mainbody_2").html(url_web)
      });
      $("#idStat_Article").click(function(){
      $("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
      $("#mainbody_2").html(url_web)
      });
      $("#idPlanets_Health").click(function(){
      $("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
      $("#mainbody_2").html(url_web)
      });
      $("#idServices").click(function(){
      $("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
      $("#left_link_index").load("Services.html #left_links_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_bio_history_gr', function(){
      $("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_info_gr', function(){
      $("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_contact_gr', function(){
      $("#mainbody").load("Services.html #contact_gr").data('url_contact_gr', "Services.html#contact_gr");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_gr');
      $("#mainbody_2").html(url_web)
      });
      });
      break;
      case 'en':
      $('[lang="gr"]').hide();
      $('[lang="en"]').show();
      $(document).ready(function(){
      $("#idR_Code_PSPP").click(function(){
      $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
      $("#left_link_index").load("R_Code_PSPP.html #left_links_en")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
      $("#mainbody_2").html(url_web)
      });
      $("#idStatistics").click(function(){
      $("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
      $("#left_link_index").load("Statistics.html #left_links_en")
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
      $("#mainbody_2").html(url_web)
      });
      $("#idStat_Article").click(function(){
      $("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
      $("#mainbody_2").html(url_web)
      });
      $("#idPlanets_Health").click(function(){
      $("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
      $("#mainbody_2").html(url_web)
      });
      $("#idServices").click(function(){
      $("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
      $("#left_link_index").load("Services.html #left_links_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_bio_history_en', function(){
      $("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_info_en', function(){
      $("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
      $("#mainbody_2").html(url_web)
      });
      $(document).on('click', '#id_contact_en', function(){
      $("#mainbody").load("Services.html #contact_en").data('url_contact_en', "Services.html#contact_en");
      var url_web = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_contact_en');
      $("#mainbody_2").html(url_web)
      });
      });
      break;
      };
      });
      </script>






      javascript jquery html external oneclick






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 21:34









      Elias EstatisticsEUElias EstatisticsEU

      134110




      134110
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438212%2fi-could-not-reload-in-single-click-external-div-contents-that-were-inserted-in-m%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438212%2fi-could-not-reload-in-single-click-external-div-contents-that-were-inserted-in-m%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin