jQuery loading problem

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 2967 Views - Last Post: 22 February 2012 - 06:38 AM

#1 C_coder   User is offline

  • D.I.C Head

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

jQuery loading problem

Posted 09 February 2012 - 02:40 AM

Hey,

So I'm have kind of a stupid problem with my jQuery requests.

Here is my code

here is my .js file caller loader
$(document.ready(function(){
	$("#response").load("index.php");
	
	
	$("#boutique").click(function(){
		$("#response").load("boutique.html");
		});
		
	$("#home").click(function(){
		$("#response").load("index.html");
		});
		
	$("#bureau").click(function(){
		$("#response").load("bureau.html");
		});



here is my menu where I click in my index.php page

<div class="header">
	<a href="#" id="boutique" class="nav">Notre Boutique |</a>
	<a href="#" id="home" class="nav">Home</a>
	<a href="#" id="bureau" class="nav">Bureau</a>



and here is the div where things should comme up when i Click in one of the menu

<div class="schema" id="response">
			</div>





Normally I should click on the menu "x", then it should go to the loader.js find the "click function and send to the div where the id is response and put it there.
But nothing happens.
I've done this once but now I can't put it to work in another page.
Can someone please help
I'm sure I've done a stupid mistake

Is This A Good Question/Topic? 0
  • +

Replies To: jQuery loading problem

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: jQuery loading problem

Posted 09 February 2012 - 02:57 AM

Hey.

I'm guessing this is the problem:
$(document.ready(function(){ ... })



The ready() function needs to be called on a jQuery object, not the normal DOM document node. So you'd do:
$(document).ready(function() { ... })



Or, even more simply:
$(function() { ... } )


This is equivalent to calling .ready on the document jQuery object.

See .ready() in the jQuery docs.

This post has been edited by Atli: 09 February 2012 - 02:59 AM

Was This Post Helpful? 1
  • +
  • -

#3 C_coder   User is offline

  • D.I.C Head

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

Re: jQuery loading problem

Posted 09 February 2012 - 03:41 AM

Corrected that, but still not working. =(
Was This Post Helpful? 0
  • +
  • -

#4 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: jQuery loading problem

Posted 09 February 2012 - 03:44 AM

Are you getting any errors?
Press CTRL+SHIFT+J (Firefox, Chrome) or F12 (IE) to get the error console up.

Are you testing this on a publicly available server, so we can see this for ourselves?
Was This Post Helpful? 0
  • +
  • -

#5 C_coder   User is offline

  • D.I.C Head

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

Re: jQuery loading problem

Posted 09 February 2012 - 04:30 AM

nop.
No errors...
I'm using wamp, localhost!

The wiard in all of this is that I've used this function once before and it workedd fine. and now I can't where the problem is.
Was This Post Helpful? 0
  • +
  • -

#6 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: jQuery loading problem

Posted 09 February 2012 - 04:54 AM

Which browser are you using?

Try installing Firebug on Firefox, or using Chrome's Developer Tools to track the request. If the .load() calls are being made, you can track those using these tools and see what is going wrong.

If not, then you can at least use them to debug the scripts: use breakpoints (or just console.log("...") calls) to see if the code is reaching the event callbacks.
Was This Post Helpful? 0
  • +
  • -

#7 C_coder   User is offline

  • D.I.C Head

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

Re: jQuery loading problem

Posted 09 February 2012 - 05:27 AM

im using Chrome with the developer tools, but no errors...
It's like the menu/link points to nothing!

I'm gonna try to rewrite it again but, I don't think that is gonna change the final result.
Was This Post Helpful? 0
  • +
  • -

#8 C_coder   User is offline

  • D.I.C Head

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

Re: jQuery loading problem

Posted 09 February 2012 - 06:42 AM

Nop, nothing changed...
Somebody has some new ideas?

If no, any ideas how I can do the same thing with other "tools"?
Was This Post Helpful? 0
  • +
  • -

#9 C_coder   User is offline

  • D.I.C Head

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

Re: jQuery loading problem

Posted 09 February 2012 - 07:05 AM

The idea is simple.
Just need to touch the link and replace the image with in the div!
Was This Post Helpful? 0
  • +
  • -

#10 revolutionx   User is offline

  • D.I.C Head

Reputation: 60
  • View blog
  • Posts: 229
  • Joined: 23-July 09

Re: jQuery loading problem

Posted 09 February 2012 - 07:14 AM

Can you upload the complete files, HTML, JS etc.

I tested it with the following code:


<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title></title>

<script>

	$(document).ready(function() {

		$("p").bind("click", function(){
			$("#targetArea").load("drag.html");
		});
     
 	});

</script>


</head>
<body>
  
  <p id="hello">Click Me</p>
  
  <div id="targetArea">
  </div>
  
  
</body>
</html>



And it works fine.
Was This Post Helpful? 0
  • +
  • -

#11 C_coder   User is offline

  • D.I.C Head

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

Re: jQuery loading problem

Posted 09 February 2012 - 07:36 AM

View Postrevolutionx, on 09 February 2012 - 07:14 AM, said:

Can you upload the complete files, HTML, JS etc.

I tested it with the following code:


<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title></title>

<script>

	$(document).ready(function() {

		$("p").bind("click", function(){
			$("#targetArea").load("drag.html");
		});
     
 	});

</script>


</head>
<body>
  
  <p id="hello">Click Me</p>
  
  <div id="targetArea">
  </div>
  
  
</body>
</html>



And it works fine.


But when you have multiple links you can't use that.
$("p").bind("click", function(){
			$("#targetArea").load("drag.html");
		});


in your "p" your are calling the "p" but if you have multiple p's how are you going to andle that?...

Thanks for the help! :tup:
Was This Post Helpful? 0
  • +
  • -

#12 revolutionx   User is offline

  • D.I.C Head

Reputation: 60
  • View blog
  • Posts: 229
  • Joined: 23-July 09

Re: jQuery loading problem

Posted 09 February 2012 - 07:42 AM

Sorry - yes, that was just an example. As P is far too general to be used like that. It should have just been #hello :sweatdrop:

You would need to create multiple bind functions, and on each one change which menu item you're binding too.

You could zip all the files you're using and upload and I can check it out for you if you want?
Was This Post Helpful? 0
  • +
  • -

#13 C_coder   User is offline

  • D.I.C Head

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

Re: jQuery loading problem

Posted 09 February 2012 - 07:44 AM

ok...I'll send you that in a sec.
Was This Post Helpful? 0
  • +
  • -

#14 C_coder   User is offline

  • D.I.C Head

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

Re: jQuery loading problem

Posted 09 February 2012 - 07:58 AM

View PostC_coder, on 09 February 2012 - 07:44 AM, said:

ok...I'll send you that in a sec.


here is the zip with the files

can you guys see the files?
I can't see them...

This post has been edited by C_coder: 09 February 2012 - 07:55 AM

Was This Post Helpful? 0
  • +
  • -

#15 revolutionx   User is offline

  • D.I.C Head

Reputation: 60
  • View blog
  • Posts: 229
  • Joined: 23-July 09

Re: jQuery loading problem

Posted 09 February 2012 - 08:03 AM

Nope, can't see them.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2