javascript - Jquery code not working on specific page -


i using advanced top menu in 1 of websites: www.vente2site.fr needed add count of number of ads links in menu. did not have other option except jquery.

on homepage: https://www.vente2site.fr/ - count working perfectly, case pages except:

https://www.vente2site.fr/e-commerces-sites-marchands-en-vente-a-ceder/2064-pret-a-porter-feminin-et-accessoires-de-modemod-elles.html - have put conditions prevent code running on page because causing 302 redirect.

it product page (prestashop 1.4.8) used page showing ad.

below code using:

function replacetext(url, inittext, text, value) {         var foundin = $('.adtm_elements_5 *:contains("' + text + '")');         //foundin.html("<table><tr><td style='vertical-align:middle'>" + inittext + </a></td></tr></table>");         foundin.html("<a href='" + url + "'>" + inittext + " ( <b style='color:#01b196;padding:0px!important;font-weight:bold;margin:0px!important;'>" + value + "</b> )</a>");         return false; }  function replacetextdataroom(url, inittext, text, value) {         var foundin = $('.adtm_elements_11 *:contains("' + text + '")');         //foundin.html("<table><tr><td style='vertical-align:middle'>" + inittext + </a></td></tr></table>");         foundin.html("<a href='" + url + "'>" + inittext + " ( <b style='color:#01b196;padding:0px!important;font-weight:bold;margin:0px!important;'>" + value + "</b> )</a>");         return false; }  function replacecount(url, inittext, text, id) {         var vars = new object();         vars['cat'] = id;           $.ajax({             type: "post",             url: "getcomptage.php",             data: vars,             success: function (msg) {                 replacetext(url, inittext, text, msg);             }         });         return false; }  function getdataroom(url, inittext, text, id) {         var vars = new object();         vars['idc'] = id;          $.ajax({             type: "post",             url: "getdataroomaccesscount.php",             data: vars,             success: function (msg) {                 replacetextdataroom(url, inittext, text, msg);             }         });         return false; }  if(window.location.href.indexof("e-commerces-sites-marchands-en-vente-a-ceder") > -1 ||     window.location.href.indexof("sites-internet-e-business-en-vente") > -1 ||     window.location.href.indexof("medias-digitaux") > -1 ||     window.location.href.indexof("saas") > -1 ||      window.location.href.indexof("applications-ios-android-fb-en-vente") > -1){  }else{         replacecount('https://www.vente2site.fr/5-e-commerces-sites-marchands-en-vente-a-ceder','sites marchands','(ccc1)', 5);         replacecount('https://www.vente2site.fr/6-sites-internet-e-business-en-vente','services en ligne','(ccc2)', 6);         replacecount('https://www.vente2site.fr/172-medias-digitaux','médias digitaux','(ccc3)', 172);         replacecount('https://www.vente2site.fr/173-saas','saas','(ccc4)', 173);         replacecount('https://www.vente2site.fr/7-applications-ios-android-fb-en-vente','apps mobiles','(ccc5)', 7);          getdataroom('https://www.vente2site.fr/repreneurdataroom.php?opp=view','datarooms auquelles jai acces','(ccc6)', {$idclient});  } 

this code called in footer of website.

you need specify absolute path php files instead of relative path. can adding slash / @ start of url you're making request to. because php files located in root of domain.

so need change functions this:

function replacecount(url, inittext, text, id) {         var vars = new object();         vars['cat'] = id;           $.ajax({             type: "post",             url: "/getcomptage.php",             data: vars,             success: function (msg) {                 replacetext(url, inittext, text, msg);             }         });         return false;     }   function getdataroom(url, inittext, text, id) {         var vars = new object();         vars['idc'] = id;          $.ajax({             type: "post",             url: "/getdataroomaccesscount.php",             data: vars,             success: function (msg) {                 replacetextdataroom(url, inittext, text, msg);             }         });         return false;     } 

Comments