Jump to content

Programming in ajax.


brianlange

Recommended Posts

I am using zend framework and jQuery.

I have a page with a list of users that can be individually deleted by clicking a link.

A jQuery script is included on this page that adds an ajax call to each "delete user" link.

Inside of the ajax call I use the jQuery load function to refresh the list of users.

The problem is that inside of the "list of users" page (separate zend framework view with no layout)  I have to reinclude the jquery script that assigns the ajax to each delete link.

It works but it seems rather clunky.  Is there a better way to do this? 

 

Link to comment
https://forums.phpfreaks.com/topic/224251-programming-in-ajax/
Share on other sites

I tried to add a recursive call inside of the ajax code but it doesn't seem to work.

assignDeleteLinks is called within "success" but it is not working.

function assignDeleteLinks()
{
    $('.delete-kid').each(function() {
   $(this).click(function(e) {
       $.ajax({type: 'POST',
               url: '/kids/delete/id/' + $(this).attr('rel'),
               success: function() {
                   $('#message').html('Kid has been deleted');
                   $('#kid-list').load('/kids/list/');
                   assignDeleteLinks(); 
               }
       });
               
              
       e.preventDefault();
          
   });
   
});
    
}

 

Link to comment
https://forums.phpfreaks.com/topic/224251-programming-in-ajax/#findComment-1158650
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.