Jump to content

jquery not working as an external


Pavlos1316

Recommended Posts

Hello,

 

I am trying to make all my scripts external but I have hit on some problems with jquery.

I have this:

$(document).ready(function(){
  $('#headerlinks > a').click(function(){
  $("#content").empty();
  var page = $(this).attr("id");
  $('#content').load("../loop_a.php?page="+ page);
   });

It is working when have it inside my <head> tags but when I call it as an ext.js file is not

That's how I call it:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="help_scripts/lnks_in_trgt_div.js"></script>

Any ideas?

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/237505-jquery-not-working-as-an-external/
Share on other sites

ok... here it is my index.php:

<?php
// check for all errors
require_once('help_scripts/check_all_errors.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled</title>
<link rel="stylesheet" media="all" type="text/css" href="style.css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="help_scripts/lnks_in_trgt_div.js"></script>
</head>
<body>
<div id="all">
<div id="header">
<?php require_once('template_header.php'); ?>
</div>
<div id="content">
<?php require_once('p_arxiki.php'); ?>
</div>
<div id="footer">
<?php require_once('template_footer.php'); ?>
</div>
</div>
</body>
</html>

 

And my lnks_in_trgt_div.js

$(document).ready(function(){
  $('#headerlinks > a').click(function(){
  $("#content").empty();//katharizei ta periexomena tou div me id=content
  var page = $(this).attr("id");//pairnei to periexomeno tou id pou klikares
  $('#content').load("loop_a.php?page="+ page);//stelnei to periexomeno tou id sto loop_a.php kai gyrna to apotelesma sto div me id=content
   });
   
  $('#footerlinks > a').click(function(){
  $("#content").empty();
  var page = $(this).attr("id");
  $('#content').load("loop_a.php?page="+ page);
   });
   
  $('#bodylinks > a').click(function(){
  $("#content").empty();
  var page = $(this).attr("id");
  $('#content').load("loop_a.php?page="+ page);
   });
});

 

my links are in the header template...

Hello,

 

I think is solved... I say I think because my cache/cookies are playing games with me...

 

Problem was on my path to loop_a.php WHICH I was trying with all possible ways and never worked (I clean my cache every time that I change something). Any other change that I was making was coming out.

 

My loop_a... NEVER. After 2 hours (and after I was 99.9% sure that it was my path and cache), I cleaned my cache once more, made sure that my path was the right one closed all pages down and restarted my ie ------ guess what... it worked.

 

I hope it continues that way  :D

 

Sorry for putting you in trouble.

 

Thank you for your help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.