views:

150

answers:

2

Hi,

I am relatively new to jquery and would like to know why the below code wouldn't work. I am trying to access the content from a file residing on my site and not outside. Is it because I have the jquery lib loading from google and not my site? The error message that I get in IE browser is "Access Denied". I am confused why the access is denied if I am trying to load a file from the same server and even same folder.

<html> 
<head>
<script type="text/javascript" language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" language="JavaScript">
$(document).ready(function(){

 $("#response").load("http://www.mydomain.com/loadme.php?route=links/getlinks&amp;path=2");
});
</script>
</head>
<body>
<div id="response" style="border: 1px solid #000;height:500px;">&nbsp;</div>
</body>
</html>

any one please help me.

thanks

+2  A: 

What happens if you try

$.get('/loadme.php?route=links/getlinks&path=2', function(data) {
  $('#response').html(data);
});

at the very least you can

alert(data)

and see if that helps you debug.

jnunn
H Jnunn, your suggestion worked for my test page but not in the place where I wanted to. I did as below in my answer and it works. the reason was I was having "javacript:void(o) in the links and when I changed it to #, it is fine except that the pages goes to the top and I guess I don't have a solution for that.
Jay
A: 

Hi,

jquery Code

$("#aboutme").click(function(){

$("#response").load("/loadme.php?route=aboutme&path=2");
});

Html code changed href ="javascript:void(0)" to "#" . The problem in using this "#" is it will go to the top of the page each time when I click on a link. I removed href=# and it works fine but not sure if its ok not to have the href

<li><a id="aboutme" href="javascript:void(0)"><span class="showcase-text">About Me</span></li>

thanks for all the hellp

Jay
sorry to post after long time. I just noticed one main thing for this to work. my site url was without www but in the links in loadme.php I had www.sitename.com. This is the main issue. After I added the rewrite url in the .htaccess to make the site work either way (with/without www), everything works fine.
Jay