Jquery - Ajax Load() Method Isn't Working
I'm trying to dynamically change the content of a div (#div1) with content from another HTML file (content.html) when a button is clicked (as is done here), but nothing happens whe
Solution 1:
Use a server
Mostly ajax issues are due to the Same Origin Policy
. There are many ways to fix this, I recommend you to use a local webserver. Setting up a local webserver is really easy:
you can use LAMP, MAMP, WAMP, or XAMPP. Those are all free and easy to use. If you aren't scared to use the command line:
- Python 3.x by running
python -m http.server
from your local directory - PHP 5.4.0+ by running
php -S localhost:<port_number>
Select only the body...
Mostly, you don't want a second doctype in your code, so replace
$("#div1").load("content.html");
With
$("#div1").load("content.html body");
Post a Comment for "Jquery - Ajax Load() Method Isn't Working"