i want to p开发者_运维问答rint all text from .js file to div
document.getElementById('cart-status').innerHTML = "/numberOfcart.js"
You could use jQuery to do something like this:
$.get('/numberOfcart.js', function(data) {
$('#cart-status').text(data);
}
but you are simply loading in the .js file, not running it.
Directly displaying the the contents of js file by JavaScript is not possible (or I don`t know, if somebody knows a way - welcome). So by PHP:
$file = file_get_contents( 'script.js' );
echo "<pre>" . htmlentities ( $file ) . "</pre>";
With an ajax callback to the php script, set to the div.
精彩评论