jquery ajax load recursive callback -


here's jquery function, i'm stuck in circular callback functions. i'm wondering how convert code call itself? or possible?

$('#content').load('myurl/items', function() {     ...     ...     $(this).find('form').submit(function(e) {         e.preventdefault();         $.ajax({             type: 'post',             url: 'myurl/items',             context: document.getelementbyid('content'),         }).done(function() {             $(this).load('/myurl/items', function(){}); // recursive         });         } }); 

declare function:

function loaditems() {     $('#content').load('myurl/items', function() {         ...         ...         $(this).find('form').submit(function(e) {             e.preventdefault();             $.ajax({                 type: 'post',                 url: 'myurl/items',                 context: document.getelementbyid('content'),             }).done(function() {                 loaditems(); // call function continue             });             }     }); }  loaditems(); // call function start 

of course, loop end if ajax call ever unsuccessful.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -