craygo Posted April 25, 2013 Share Posted April 25, 2013 I have a pretty simple list which comes from a table. I initially show only a couple fields in the list but have an icon which when clicked will load a div with all the details for that row. it works fine but for some reason everytime I click the link it requests the page exponentialy. here is the link <a href="/media/pdet/'.$r->PID.'" class="load" /><img src="/assets/media/img/info.png" alt="edit" title="Details" border="0" /></a> here is the jquery function $(function(){ $("a.load").click(function (e) { e.preventDefault(); $("#pdetails").show("slow"); $("#projd").load($(this).attr("href")); }); }); #pdetails is the main div and #projd is the div the page gets loaded into. And here is the web console from firefox showing what happens [08:44:55.653] GET http://192.168.20.13/media/pdet/10 [HTTP/1.1 200 OK 63ms] [08:44:59.672] GET http://192.168.20.13/media/pdet/13 [HTTP/1.1 200 OK 62ms] [08:44:59.751] GET http://192.168.20.13/media/pdet/13 [HTTP/1.1 200 OK 62ms] [08:45:02.472] GET http://192.168.20.13/media/pdet/11 [HTTP/1.1 200 OK 62ms] [08:45:02.555] GET http://192.168.20.13/media/pdet/11 [HTTP/1.1 200 OK 62ms] [08:45:02.625] GET http://192.168.20.13/media/pdet/11 [HTTP/1.1 200 OK 61ms] [08:45:02.699] GET http://192.168.20.13/media/pdet/11 [HTTP/1.1 200 OK 62ms] [08:45:05.677] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 65ms] [08:45:05.754] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 63ms] [08:45:05.825] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 63ms] [08:45:05.892] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 62ms] [08:45:05.967] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 62ms] [08:45:06.037] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 62ms] [08:45:06.106] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 61ms] [08:45:06.182] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 62ms] as you can see when I click on a link the first time it request once, then click another it request twice, the third time it runs four times and so on. If I refresh the page it resets. Thanks in advance for your help. Ray Quote Link to comment https://forums.phpfreaks.com/topic/277299-ajax-requesting-multiple-times/ Share on other sites More sharing options...
PaperTiger Posted April 28, 2013 Share Posted April 28, 2013 Try unbinding the click event before you set it: $(function(){ $("a.load").unbind('click'); $("a.load").click(function (e) { e.preventDefault(); $("#pdetails").show("slow"); $("#projd").load($(this).attr("href")); }); }); Quote Link to comment https://forums.phpfreaks.com/topic/277299-ajax-requesting-multiple-times/#findComment-1426900 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.