javascript - AJAX stop working on loading same site different PHP id -


so have website i'm doing school project. it's supposed pastebin. on right theres different div (uued koodid) shows newest pastes. on click, supposed show include using ajax refresh left div. works 4 times , stops, url still changing. after refresh changes again , works again 4 more times.

in main.js have

... $.ajaxsetup({ cache: false }); ... $(".uuedkoodid").click(function () {     $(".left-content").load(document.location.hash.substr(1)); }); ... 

edit: other ajax functions work. if log in, can switch between settings , profile still cannot watch new codes

when replace right menu new code (from ajax call) don't attach click event again on .uuedkoodid items don't anything. need attach event again or attach this:

$(document).on('click', '.uuedkoodid', function () {   $(".left-content").load(document.location.hash.substr(1)); }); 

edit: noticed cause small problem. onclick event run before browser run standard link action. first load ajax , browser changes address. way 1 action behind. better solution reading delay (settimeout) think read address directly link:

$(document).on('click', '.uuedkoodid', function () {   var url = $(this).attr('href');   $(".left-content").load(url.substring(url.indexof("#")+1)); }); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -