I don't know much about .htaccess but I do believe part the solution to your problem is to move the jQuery outside of the php tags as so:
?>
$(document).ready();
your file is going to be parsed as any other php file, so your javascript will execute as normal, inside of javascript tags.
if you would like to include php variables inside your javascript just do as so:
$time=time();
?>
$( document ).ready(function(){
$("SPAN").text(" echo $time; ?>");
});
the above code will return the current epoch timestamp inside of the SPAN element