This seems like such a simple thing but it has me stuck.
I have a function inside a function in a .js file that gets included in a PHP page. I simply need to pass it a PHP var and I keep getting various errors (usually syntax) no matter how I try.
Here’s the pertinent content of the .js file:
[CODE]$(document).ready(function() {
[… cut code …]
$(“#country_id”).change(function zoneData(countryID, zoneID, name, zoneName) {
$.ajax({
url: ‘<?php echo base_url(); ?>’ + countryID + ‘/’ + zoneID + ‘/’ + name + ‘/six/’ + zoneName,
type: ‘POST’,
success: function(data) {
$(‘#zone_name’).html(data);
}
});
});
});
Note the base_url() in the url section. That’s what I need filled.
I’ve tried that, I’ve tried putting it in the function arguements and replacing it with a var. I’ve tried json_encode as a var and passing that to the function. Looking at the console and the HTML source, nothing I do generates the actual base_url value, it ALWAYS displays the literal <?php…?> script, regardless of quotes or escaping….
Any suggestions? ?
Thanks for any help!