Thursday 15 August 2013

java - jquery: load/include html code into html file without delay? -


I'm working on a mobile app that uses Cordova, so it's basically running in an app Is an HTML-website. And I have a lot of elements and HTML-code that are present on all pages, e.g. Also on popups navigation and so on and so on

When working on large Web projects, I usually wrap these types of code sections in php-files and use "php included" to create my html files. Even though I can not work with PHP because there is no server, so since I would like to avoid having multiple copies of the same code in every HTML-file, I would like to include the HTML code in the HTML code using jquery Looking for a way to?

I tried to do this with:

  $ ("# includeContent1"). Load ("mod_navigation.html");  

and

  $ Get ('mod_navigation.html', function (data) {$ ('body'). Append (data);});  

Both used to work, were not as great as PHP, but did the trick. The problem is that loading additional content (navigation in this case) is shown after the "parent HTML file", popping up navigation with a slight delay, it just looks awful, because the screen used when using the app Navigation is just flickering at the bottom.

Is there any way to avoid these delays? Maybe everything in the html file is loading ... or any other way? Maybe by jumping on the new page ...

Can you try to create a complete DOM in only one variable, and when all the HTML The code is saved in the variable, then it is added to the body? Say

$ ("body"). Blank (); // Clear All Content Contents = ""; / * Start making content here * / $ ("body") Attachment (content);

Althoug I do not know how fast it is ...

Cheers


1 comment: