PDA

View Full Version : New to javascript. quick question



jeff5656
Feb 12th, 2012, 08:18 PM
I put the jquery script into my subdirectory. In the header which one is correct:


<script type="text/javascript" src="../jquery/jquery.js"></script>
or


<script src="../jquery/jquery.js"></script>

And there is this code: do I put this in the body and enclose it with the <script>tag?

$(function(){
// set interval for 5 minutes
setInterval(function(){
$.ajax({url: "keep-alive.php"});
}, 300000);
});

Philip M
Feb 12th, 2012, 08:27 PM
a) As type = "text/javascsript" is the default, there is no difference between them, but it is preferable to use <script type = "text/javascript">

b) Yes.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

felgall
Feb 12th, 2012, 08:49 PM
<script type="text/javascript" src="../jquery/jquery.js"></script>
<script type="text/javascript">
$(function(){
// set interval for 5 minutes
setInterval(function(){
$.ajax({url: "keep-alive.php"});
}, 300000);
});</script>