That title is a mouthful and a bit confusing, but you are still reading this so I guess there's hope.
I have a workflow interface that has several different types of steps that can be added. I am creating each step type independently in its own PHP file. When a step needs to be loaded, I call $.post, passing some JSON, and get the response back to display in my workflow builder.
There are currently 5 types of steps. Getting the HTML/DOM from the $.post on demand is slow. I would like to get all of the step's HTML/DOM by doing a $.post to each page up front, at the end of the page or the bottom of $.ready. That way, when a step needs to be loaded, I'll pull the HTML/DOM out of the JSON storage object. I will have everything I need and the user won't have to wait.
Here's my question, as I've not done it this way before. If someone selects a step as soon as the workflow interface is rendered, there's a good chance that step type won't be in the JSON storage object yet. In that case, I'm thinking I'd have to go out and get it for rendering. I would then want to put in the array for later use.
I'm thinking through this and am wondering how this could work. Will my UI even be available while I build the JSON object that will 开发者_JAVA技巧hold the step's HTML/DOM? If not, how can I make it available and do all that asynchronously? How do I ensure that I don't try and write the same HTML to my JSON object at the same time? I've considered building all the steps in a separate HTML file so I'm only making one call, but it would be nice to have the HTML/DOM's available as they are loaded.
Hope I'm making sense. I've done some research on this, but I'm hoping someone out there has done this and would save me some time.
Thanks gang!
In your instance, you might consider blocking your gui or disabling whatever interface it is that makes the requests for the workflow HTML. That would be one way of doing.
I think that would be your safest option, because otherwise you will end up doubling up on requests and just wasting bandwidth that you might want to use for other AJAX requests etc.
精彩评论