This question already has an answer here:
I have the following defined in my controller:
$data['is_amazon'] = $product->is_amazon;
$data['is_ebay'] = $product->is_ebay;
Directly below this in the controller I'm calling a .js file (jQuery).
$this->template->add_js('js/is_ebay_amazon_prouct_edit.js');
I'd like to access these php variables in my jQuery script, I've tried this approach:
var amazon = '<?php echo $is_amazon; ?>';
var ebay = '<?php echo $is_ebay; ?>';
jQuery(document).ready(function($) {
alert(amazon);
//alert(ebay);
});
Although this just displays my physical text in the alert, I.E:
<?php echo $is_ebay; ?>
What is the best approach here in terms of making these variables accessible in my jQuery?
</div>