javascript - jQuery append, wait till rendered with no timeout -


I have an AJAX that adds HTML to the page with jQuery's append method HTML is something big and I can change the colors of the cells , Those colors have been determined by CSS in the same HTML document.

My problem is that, if I loop cells immediately after append method, then all the cells have no color, I have to wait a few seconds to work. Right now, I am ending a time to start looping through the cells, but I do not want to do this. I want to know 1) Why the page has not been provided with an attachment, why HTML is sung completely and 2) What options do I have?

I am thinking of putting an interval to check for the specific value of a cell at the end of HTML, but I am not very happy with that approach.

Thank you!

Do not use interval on AJAX responses. They work if you set enough time for the time, but you have to set for maximum time, who requests you to take, which still has the chance to fail after 5 seconds. In addition, if the request takes milliseconds, nothing will happen for the second second of 4.99 seconds (if 5 seconds is your timeout).

AJAX functions take many parameters, some of which are strings (such as "content-type: 'app / jsans''). Some items are (like data: {requestId: 999} ). You can also provide other functions as parameters, depending on the $. Ajax () takes such arguments (called 'callback') and comes back from request You can provide a error: callback that will only be executed when there is an error There is a root code (such as 404 or 500). A is a success: A callback that will be executed immediately after successful content, whether it is 1 millisecond or 5 seconds.

Wherever you are going through the argument in your $. Ajax () function, give it something like the following:

  // ... other logic success: Function (feedback) {$ ('# myTable'). Html (response);}); // and arguments   

that function will be executed properly / when Successful response is a must have to tell me that this callback can take its own arguments, among others, the actual content from the request is one of them (in the above example it is the first argument, feedback ). Whether you have XML or JSN or HTML, what will happen in your response for the function to function accordingly

You are already using callback, but since no one code and I added 'timeout' with the word 'AJX', I am feeling that this is your answer.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -