- 1
.load function in Jquery isn't working. Can anybody tell me where i am going wrong?
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").load("demo_test.txt"); }); }); </script> </head> <body> <div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div> <button>Get External Content</button> </body> </html>
9 Answers
+ 5
Your code work well if the file 'demo_test.txt' exist in the same folder than your source code file ^^
However, it could not work in code playground with other url than abssolute (complete urls), as relative location will be on sololearn servers, where you cannot upload any external ressources for your web projects in playground (or anywhere, but elsewhere you could have required right to do so)... This means also that for working in code playground, you need to upload any external ressources somewhere on internet ;P
+ 4
It work well for me, with local files...
Are you sure of the text file name? You wrote 'demo_test.txt' in your code and 'demo_txt' in your reply ;P
+ 4
If your are on unix-like OS (linux, OSX...) and even on Window (but less probable), you need to verify the file rights (user, group, read access...)
+ 3
No default: it's working ^^
0
I haven't tried this code in Sololearn code playground... But the demo_txt file is present in the same directory
0
The demo_test.txt doesn't open when I clicked the button... There is no error though
- 1
I meant that actually :P...
- 1
Can you please tell me if there is any flaw in the code please?
- 1
Are there any plugins I need to include?