I need to load a php file as shown below."How can i 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 i insert or load php code " < /div>").append(aj);
$("#tabs").tabs("refresh");
});
});
</script>
You just need to pass the num_tabs
value in your PHP file. Here in my example i have passed it using tab_num
variable.
Get the tab_num
variable using $_GET
in your PHP file. Then just echo
your desired HTML
in the PHP file and you will get the data in your 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>';