Is putting an ajax request within an ajax request weird and convoluted or a good solution?

Is putting an ajax request within an ajax request weird and convoluted or a good solution?
0.0 0

#1

I finally figured out a way to get the display name and the status of the stream by doing this. It seems to work, but I was just wondering if this is a normal way to do it, or if there is a better way.

Before I had two different function: one to get the display name and the other to get the stream status. I think what was happening was they were working simultaneously and things were getting confused. But then when I nested one request within another it seemed to solve it.

Just wondering if any more experience coders would do it this way? I was thinking it could be brilliant, or just really convoluted. Let me know what you think. (Please ignore the style, this is not my final version of this project at all).


#2

I wouldn’t say it’s weird (did that before, and at that time, it seemed to be the only option), but I guess you can say it can get convoluted, and opens the highway to callback hell (another).

I haven’t tried this yet (for this project), but check out Promises.


#3

One thing that you might find is that it will add latency. I would say chaining the requests would be a better description for what you are doing than meeting.

If reach request takes say 100ms, then chaining them together means the whole thing will take 200ms. If you can figure out a way of sending both requests at the start, you cut the time in half.


#4

Thanks for the reply. although it did seem to work, I’ve been tweaking things around and I realized that I don’t absolutely have to do it this way. Now I’m having other issues. I keep getting a little closer to finishing this project, but so far this one has take n the longest.


#5

Sorry for the slow reply, but thanks for the feedback. I’m still fiddling with it. I found a way to not have to nest them. I don’t know exactly what callback hell is, but I have a feeling I’ve at least visited callback purgatory while working on this project.