jquery - How to load a php or html file in append -


i need load php file shown below."how can insert or load php code"

<script> $(document).ready(function() {      $("#tabs").tabs();     $("#btn2").click(function() {         var num_tabs = $("div#tabs ul li").length + 1;         $("#tabs ul").append("<li><a href='#tabs-" + num_tabs + "'>ajay#" +             num_tabs + "</a></li>");         $("div#tabs").append("<div id='tabs-" + num_tabs + "'>"             how can insert or load php code " < /div>").append(aj);         $("#tabs").tabs("refresh");      });  }); </script> 

you need pass num_tabs value in php file. here in example have passed using tab_num variable.

get tab_num variable using $_get in php file. echo desired html in php file , data in data variable.

<script> $(document).ready(function() {      $("#tabs").tabs();     $("#btn2").click(function() {         var num_tabs = $("div#tabs ul li").length + 1;          $.get("filename.php", {             tab_num: num_tabs         }, function(data) {             $("#tabs ul").append(data);         });           $.get("filename.php", {             tab_num: num_tabs         }, function(data) {             $("div#tabs").append(data);         });           $("#tabs").tabs("refresh");     });  }); </script> 

filename.php

echo '<div id="tabs-'.$_get['tab_num'].'"><div id="aj"></div></div>'; 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -