I'm trying to print some PHP content inside a simple Javascript call. The first one I got, but I have 2 vars to include, and one of them, must to be inside a .load().
I'll put the code bellow for a better understanding:
<?php
$loadclass = 'filtersin';
$load_address = 'recebimento-filter';
$modal_ID = 'FilterModal';
?>
The JS calling (and what I'm trying to do):
<script>
$(document).ready(function(){
var loadclass="<?php echo '.', $loadclass; ?>";
var load_address="<?php echo $load_address, '.php' ?>";
$(loadclass).load("dialogs/filter_group/",$(load_address) );
});
</script>
Change
$(loadclass).load("dialogs/filter_group/",$(load_address) );
To
$('.' + loadclass).load("dialogs/filter_group/" + load_address );
loadclass
is now a class. Notice the .
load_address
properly Description: Load data from the server and place the returned HTML into the matched element.
So, if dialogs/filter_group/recebimento-filter
does not return HTML it won't work as expected.
To fix this you can add a rewrite rule to .htaccess
Replace:
var loadclass="<?php echo '.', $loadclass; ?>";
var load_address="<?php echo $load_address, '.php' ?>";
$(loadclass).load("dialogs/filter_group/",$(load_address) );
with
var loadclass="<?php echo '.' . $loadclass"; ?>";
var load_address="<?php echo $load_address . '.php'; ?>";
$(loadclass).load("dialogs/filter_group/" + load_address );
The string concatenatio sign is '.' in php and '+' in javascript, not ','
Simpler:
$("<?='.' . $loadclass ?>").load("dialogs/filter_group/<?= $load_address . '.php' ?>");
In both cases (with your initial values) results in:
$(".filtersin").load("dialogs/filter_group/recebimento-filter.php");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.