Uploading local files via jQuery

Spent 3 hours reading the link, but still no effect, so please here.

OS: Windows 7 (is this relevant?)
Browser: Opera 11.51
jQuery: 1.6.2


Two files on the local computer, main.html and menu.html in the same folder.

main.html:

<html> <head> <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ // append contents $('#menu').load('menu.html'); }); </script> </head> <body> <table> <tr> <td id="menu"></td> </tr> </table> </body> </html> 

menu.html:

 <html> <head></head> <body> menu tree </body> </html> 

As I think, when I open main.html, there should be one table with one cell containing a menu tree line. And it works, for example, in IE. But Opera does not show any result.

I debugged the material with an additional callback for load (), it shows that the state of the result for load () is an β€œerror”.

What am I doing wrong?

+1
source share
2 answers

In Opera, you must set the Allow File XMLHttpRequest flag (opera: cofig - User Prefs).

In Google Chrome, you should use the parameter parameter --allow-file-access-from-files to start the browser, for example: "C: \ Documents and Settings \ User \ Local Settings \ Application Data \ Google \ Chrome \ Application \ chrome.exe "--allow-file-access-from-files

+4
source

You will probably want to get rid of the <body> , <head> and <html> tags in Menu.html.

The way you do this now is invalid HTML because only <body> , <head> and <html> tags are allowed in the document.

Change Menu.Html to

 <p> Menu </p> 

Try it!

0
source

All Articles