Reputation: 11985
I would like to achieve that when clicking in an image, in the div where this image is, a div with other content from another .html is loaded, but I can't get it done.
If I do, the following, it works perfectly:
$('#windows_link').click(function(){
$('#apps_container').html("Hi!");
});
But if I do the following, it does not work; it doesn't do anything actually:
$('#windows_link').click(function(){
$('#apps_container').load('windows_apps.html #apps_container');
});
Any help, please?
Thanks a lot in advance!
Upvotes: 2
Views: 651
Reputation: 630627
When you're local any other HTML path is treated as another domain in certain browsers (Chrome is on the list). That means any AJAX request (what .load()
does underneath) you attempt will be blocked by the same origin policy.
What you have will likely work fine...just not locally, in Chrome.
You can verify this by testing in another browser like Firefox, or by launching chrome with a command line switch to disable this safety feature (only for testing!, turn it off after):
chrome.exe --disable-web-security
Upvotes: 3
Reputation: 76910
If the first try works correctly, i assume the problem is here
.load('windows_apps.html #apps_container');
When you click the link, do you see a call in your .net panel of firebug or of your debugging console(does the ajax call complete succesfully)?
Is windows_apps.html in the same folder of the page script that calls it?
is there a div called apps_container into that page?
Upvotes: 0