jquery - How to avoid to fetch remote response each time in tab -


I'm getting the response from the remote source for the tab I am using the bootstreap tab, every time I click on the remote Data content is received every time a remote source is called. I want that remote sources to be called for the first time only.

My link is

  $ (document) .ready (function () {$ ('[data-toggle =' Tablet "] '). Click (function (E) {var $ this = $ (this), loadurl = $ this.attr ('href'), targ = $ this.attr ('data-target'); $ .get (loader, function) { $ (Tarrug) .html (data);}); $ thistab ('show'); return;});})  

How to get it After loading, you can add some data to the target the first time, and test it:

  if (! $ (Targ) .data ('loaded')) {console.log ('data not loaded first happened'); $ .get (loadurl, function) {// Here you make the "loaded" state $ (targu) .html (data) targets "flag." Data ('filled', true);} ); } Else {console.log ('The data was already loaded');  Note:  You can trigger a click on the first tab after loading the page  
  $ ('[ Data-toggle = "tabList"]: first click on '). To disable AJAX loading on the first tab  

or , use this test instead:

  if (! $ (Targ) data ('load') & amp; amp; $ this.parent ('li'). Index ()! == 0)  

or if you can , Then just attribute data-loaded on the first target:

  & lt; Div class = "tab-panel active" id = "a" data-loaded = "1" & gt;  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -