meera kibe
meera kibe

Reputation: 1

simple ajax load() not working in jquery

I am trying to figure out what is wrong with the function load() not working in Chrome and Firefox. Using Internet Explorer it works beautifully.

I have a WampServer.

In Chrome, I get error:

Origin null is not allowed by Access-Control-Allow-Origin

I put files on local server, it is on-line. I can access an image, see code. But what goes wrong with load()?

<body>
    here is a image
    <img src="/wamp/www/testing/baby2.jpg" width="100px" height="200px"></img>   

    <ul id="aj">
        <li><a href="/wamp/www/testing/celeb1.html">One</a></li>
        <li><a href="/wamp/www/testing/celeb2.html">Two</a></li>
        <li><a href="/wamp/www/testing/celeb3.html">Three</a></li>
    </ul>
    <br>
    <div id="desc">

    </div>

    <script>
    $(document).ready(function(){
        $('#aj a').click(function(){
            var v= $(this).attr('href');

            $('#desc').load(v);
            return false;
        });
    });//ready
    </script>
</body>

Thanks in advance.

Upvotes: 0

Views: 415

Answers (3)

hohner
hohner

Reputation: 11588

In your Apache settings (go to the file named httpd.conf in your WAMP installation), what are you specifying for your Home Directory? This is what your browser will go to when you use links which start with a forward slash, such as /testing/celeb1.html.

Normally, it'll be something like /wamp/www/. Because of this, you then only ever have to use the /testing/... part of the URI for hyperlinks.

Upvotes: 0

jsshah
jsshah

Reputation: 1741

This is a problem with Chrome: see this bug and also this answer.

You may need to start Chrome using a special command line flag:

chrome.exe --allow-file-access-from-files

Upvotes: 1

Sameh Serag
Sameh Serag

Reputation: 746

I think the problem in URL

try to write them like ....

     <ul id="aj">
       <li><a href="/testing/celeb1.html">One</a></li>
       <li><a href="/testing/celeb2.html">Two</a></li>
       <li><a href="/testing/celeb3.html">Three</a></li>
    </ul>

You can also take a look @ this Topic

Upvotes: 1

Related Questions