Recently, using the jquery load () method in the project to load the page, first simply say the load () method.
Load (Url,data,callback), this method receives three parameters, the first one is the loaded page address, the second is the parameter to be uploaded to the server, and the third is a callback function that executes after the page is loaded successfully. Of these three parameters, data and callback are optional according to the specific project requirements. Here's the problem: put an empty div container on the page to load the new page, and after loading, you need to control the hidden state of the elements in the new page, which needs to get the elements loaded into the page and then proceed to the next step. Loading the page after the review element, loaded page content directly in the div container, I was in the load (URL) method, directly get the element to hide, but loaded page elements are not hidden, it was very confusing, I thought I was not introduced through the IFRAME page, why can't hide it? Later on-line search, and colleagues consulted, finally found a solution, in the load (Url,callback) method with a callback function, inside the callback function to get the element and hidden. This is why, personally, it may be related to the JS execution sequence, after the execution of the load (URL), the following code continues to execute, will not wait until load () execution is complete. Later on the web, the load () method loads the page asynchronously, so the page element is only available in the callback of load (). So, this small problem cost two hours of time, or the foundation is not solid AH. From this extension, the load () method loading page can in some cases replace the previously used IFRAME loading page, and there is an opportunity to try it later.
Controls loading elements from a new page using the jquery load () method