I have a array in php file say
<?php $authcode = array("auth"=>"jshkjashdkj");?>
Now I want to access this array in a JS file, then how can I do it?
As in .js file <?php echo json_encode($authcode); ?>
wont work.
UDPATED
My custom.js file contains below code,where I have to use authcode in url:
$('#removeimage').click(function(){
$.ajax({
url:'deletefile.php?filename='+$('#filename').val()+'&make='+$('#make').val()+'&model='+$('#model').val(),
cache: false,
async: false,
dataType: "json",
success: function(data) {
window.location="/upload/?authcode=97A434B1-E250-490D-8CF1-4B664AB42EED&make="+data.make+"&model="+data.model+"&imagename="+data.filename;
},
error: function(data) {
alert("Service is down");
}
});
});
Please notice the authcode usage, thats the place I need to use my authcode array
Please guide me.