Skip to main content
deleted 6 characters in body
Source Link
P.Brian.Mackey
  • 11.1k
  • 8
  • 53
  • 88

I also have a series of web based services which need to be called in order. I solved the issue with AJAX. The key is having a callback mechanism to perform the recursion, forcing synchronization.

Something like this (jQuery)

function Recurse(params) { $.get(url, {params}, function (data) {Recurse(data)}//callback does recursive call, also passes in variable data received from the web service ,'html'); } 

You should check the API in question to see if it is a tree data structure like the DOM. Usually recursion is a good approach to iterate trees. If it's just a flat, linear API then a Queue/Stack can be used to push/pop your way through the API recursively.

Here's how to recursively iterate the DOM. Code for another Tree based API structure will be similar (javascript)

function walk(node, func) { //walk the height of the tree func(node);//do something to the node node = node.firstChild; while(node, func) { //walk siblings walk(node, func); node = node.nextSibling; } } 

I also have a series of web based services which need to be called in order. I solved the issue with AJAX. The key is having a callback mechanism to perform the recursion, forcing synchronization.

Something like this (jQuery)

function Recurse(params) { $.get(url, {params}, function (data) {Recurse(data)}//callback does recursive call, also passes in variable data received from the web service ,'html'); } 

You should check the API in question to see if it is a tree data structure like the DOM. Usually recursion is a good approach to iterate trees. If it's just a flat, linear API then a Queue/Stack can be used to push/pop your way through the API recursively.

Here's how to recursively iterate the DOM. Code for another Tree based API structure will be similar (javascript)

function walk(node, func) { //walk the height of the tree func(node); node = node.firstChild; while(node, func) { //walk siblings walk(node, func); node = node.nextSibling; } } 

I also have a series of web based services which need to be called in order. I solved the issue with AJAX. The key is having a callback mechanism to perform the recursion, forcing synchronization.

Something like this (jQuery)

function Recurse(params) { $.get(url, {params}, function (data) {Recurse(data)}//callback does recursive call, also passes in variable data received from the web service ,'html'); } 

You should check the API in question to see if it is a tree data structure like the DOM. Usually recursion is a good approach to iterate trees. If it's just a flat, linear API then a Queue/Stack can be used to push/pop your way through the API recursively.

Here's how to recursively iterate the DOM. Code for another Tree based API structure will be similar (javascript)

function walk(node, func) { //walk the height of the tree func(node);//do something to the node node = node.firstChild; while(node) { //walk siblings walk(node, func); node = node.nextSibling; } } 
added 320 characters in body
Source Link
P.Brian.Mackey
  • 11.1k
  • 8
  • 53
  • 88

I also have a series of web based services which need to be called in order. I solved the issue with AJAX. The key is having a callback mechanism to perform the recursion, forcing synchronization.

Something like this (jQuery)

function Recurse(params) { $.get(url, {params}, function (data) {Recurse(data)}//callback does recursive call, also passes in variable data received from the web service ,'html'); } 

You should check the API in question to see if it is a tree data structure like the DOM. Usually recursion is a good approach to iterate trees. If it's just a flat, linear API then a Queue/Stack can be used to push/pop your way through the API recursively.

Here's how to recursively iterate the DOM. Code for another Tree based API structure will be similar (javascript)

function walk(node, func) { //walk the height of the tree func(node); node = node.firstChild; while(node, func) { //walk siblings walk(node, func); node = node.nextSibling; } } 

I also have a series of web based services which need to be called in order. I solved the issue with AJAX. The key is having a callback mechanism to perform the recursion, forcing synchronization.

Something like this (jQuery)

function Recurse(params) { $.get(url, {params}, function (data) {Recurse(data)}//callback does recursive call, also passes in variable data received from the web service ,'html'); } 

I also have a series of web based services which need to be called in order. I solved the issue with AJAX. The key is having a callback mechanism to perform the recursion, forcing synchronization.

Something like this (jQuery)

function Recurse(params) { $.get(url, {params}, function (data) {Recurse(data)}//callback does recursive call, also passes in variable data received from the web service ,'html'); } 

You should check the API in question to see if it is a tree data structure like the DOM. Usually recursion is a good approach to iterate trees. If it's just a flat, linear API then a Queue/Stack can be used to push/pop your way through the API recursively.

Here's how to recursively iterate the DOM. Code for another Tree based API structure will be similar (javascript)

function walk(node, func) { //walk the height of the tree func(node); node = node.firstChild; while(node, func) { //walk siblings walk(node, func); node = node.nextSibling; } } 
Source Link
P.Brian.Mackey
  • 11.1k
  • 8
  • 53
  • 88

I also have a series of web based services which need to be called in order. I solved the issue with AJAX. The key is having a callback mechanism to perform the recursion, forcing synchronization.

Something like this (jQuery)

function Recurse(params) { $.get(url, {params}, function (data) {Recurse(data)}//callback does recursive call, also passes in variable data received from the web service ,'html'); }