javascript - $.each functionality differs with object type -


when $.each statement looks this:

 $.each($(".permissions"), function (index, element) { ... }).promise().done(function () {...}); 

it works.

when $.each statement looks this:

 $.each(dataobj, function (index, element) {  }.promise().done(function () {...}); 

returns error:

$.each.promise not function

why that? can workaround?

there ajax script in done function want run after $.each avoid race condition.

you don't need .promise() here @ all. $.each synchronous, there never "race condition" here. code not continue until $.each finished.

just run $.ajax call when $.each done.

$.each(dataobj, function (index, element) { }); $.ajax({}); 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -