11 Replies - 2403 Views - Last Post: 27 March 2012 - 02:56 PM

#1 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Problem with jQuery

Posted 22 February 2012 - 09:01 AM

hei.

So, i got a bit of a problem...I'm using this bit of code:
<script>
$(document).ready(function() {


	$("#header > a").click(function(e) {
		
		var self = $(this);
		
	
		$("#image").load(self.attr("p_bureau.html"));
		
		
		e.preventDefault();
	});
 
});

</script>




everything is going right, except that in ome of my hrefs I've got a php include but the include does get read by the page...

Any suggestions?

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with jQuery

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3047
  • View blog
  • Posts: 4,562
  • Joined: 08-June 10

Re: Problem with jQuery

Posted 22 February 2012 - 09:13 AM

This doesn't make sense:
$("#image").load(self.attr("p_bureau.html"));


Shouldn't that be attr("href")? (I thought we covered that in an earlier thread.)


Anyhow, what is the value of the href that you are loading? Could it be that you are using .html where you should be using .php? - Remember that PHP code is not interpreted within HTML files, only PHP files. (Unless specifically configured to do so, which is not the norm.)
Was This Post Helpful? 1
  • +
  • -

#3 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Re: Problem with jQuery

Posted 22 February 2012 - 09:29 AM

sorry, i copied the code from the former thread but that part is ok.

and not, the page that i'm loading is a .php
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3047
  • View blog
  • Posts: 4,562
  • Joined: 08-June 10

Re: Problem with jQuery

Posted 22 February 2012 - 09:40 AM

What happens when you load the page directly? Does the include work then? - What exactly is the output of the page?

This doesn't really seem like a problem with jQuery or AJAX. All that does is make a HTTP request. If the PHP include is failing then the fault for that is more likely with the PHP code or the HTTP server configuration.
Was This Post Helpful? 0
  • +
  • -

#5 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Re: Problem with jQuery

Posted 22 February 2012 - 11:23 PM

so in the page that I want to open I have a href to an image and a include

When I have only the href to the image it works fine, and when I only have the href to the page that i putten in the include it works fine...but when I put the image and include the other page on the include, the include doesn't work...so I think the problem is the include.

but i can't solve it, do you know how to solve this?
Was This Post Helpful? 0
  • +
  • -

#6 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3047
  • View blog
  • Posts: 4,562
  • Joined: 08-June 10

Re: Problem with jQuery

Posted 23 February 2012 - 05:27 AM

Can you show us the code?
Was This Post Helpful? 0
  • +
  • -

#7 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Re: Problem with jQuery

Posted 23 February 2012 - 06:25 AM

here is my index.php page with the load function:
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/layout.css" />
<script src="js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/loader.js"></script>

<script>
$(document).ready(function() {


	$("#header > a").click(function(e) { //Use the links hat are in the #header
		
		var self = $(this);
		
	
		$("#image").load(self.attr("href"));//send them to #image
		
		
		e.preventDefault();
	});

});
</script>

</head>




	<div class="header" id="header">
			<nav><?php include ('header.php'); ?><nav>
	</div>
	
<body>


	<div class="container">

		<div class="content">

			<div class="schema" id="image">
			<!--<?php include ('home.php'); ?>-->
			</div>

		</div>

	
		<div class="footer">
			<?php include ('footer.php'); ?>
		</div>
	</div>

</body>

</html>



and here is a random page that you can find by clicking in one of the menu in the header. page: bureau.php


<img src="schemas/SchemaBureau.jpg" />
<?php include('select1.php'); ?>




ok...I got it working but the image that I have doesn't keeps the layout that it used to...

It's like 10x bigger than normal
Was This Post Helpful? 0
  • +
  • -

#8 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Re: Problem with jQuery

Posted 06 March 2012 - 03:10 PM

hey again...so my code is working...but now I would like to use it as an external file...
I've created the .js file and I've included in the header area...but is not working...
any ideas?
Was This Post Helpful? 0
  • +
  • -

#9 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Re: Problem with jQuery

Posted 26 March 2012 - 10:21 AM

Hey again guys....for those who didn't see this tread last time you can read in the posts above my problem for those who did helped me last time and that I thank a lot for it I shall ask for your help again...

My problem is pretty much the saime as in the beggining of this thread!

I tried to implement in another project the last code that was created in this thread and is not working. Below I'll post my code, I'm sure I just missed a pretty dumn thing but I can't figure out what...

This is my script that is included in the head od the index page

<script>
$(document).ready(function() {


	$("#sidebar > a").click(function(e) { //Use the links hat are in the #header
		
		var self = $(this);
		
	
		$(".article").load(self.attr("href"));//send them to #image
		
		
		e.preventDefault();
	});

});
</script>






This is my div for the menu bar
<div class="sidebar" id="sidebar"><?php include ("sidebar_left_menu.php"); ?>
        
    </div>




And this is the div where it should end up
<div  id="article" class="article"> </div>



Oh, an this is my menu:
<a href="member_profile.php" id="myprofile" class="nav">Menu1.</a>




Thanks in advanced for your help!
Was This Post Helpful? 0
  • +
  • -

#10 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Re: Problem with jQuery

Posted 26 March 2012 - 12:58 PM

Please...somebody help me...I'm sure is really small error but can't find it....Tried a few variables but nothing worked
Was This Post Helpful? 0
  • +
  • -

#11 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Re: Problem with jQuery

Posted 27 March 2012 - 12:53 PM

No forum leaders around here? Please some help...tried so many things that is like impossible that it doesn't work...but still doesn't work!
Was This Post Helpful? 0
  • +
  • -

#12 C_coder  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 25-May 11

Re: Problem with jQuery

Posted 27 March 2012 - 02:56 PM

OK...solved the problem with AJAX...Thanks for the help!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1