Jump to content

ajax requesting multiple times


craygo

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/277299-ajax-requesting-multiple-times/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.