且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery中的.load()方法给我404-找不到错误

更新时间:2023-11-18 17:04:40

像克劳迪奥·雷迪(Claudio Redi)所说的...

Like Claudio Redi said...

您正在尝试加载相对于您所在路径的文件.尝试对文件路径进行硬编码,然后在浏览器中查看它,然后将其加载.

you're trying to load a file relative to the path you are at. Try hard coding the file path and then viewing it your browser and then it should load.

因此您的行将如下所示(如果文件位于WEBROOT/MY_APP/Files中)

so your line will be like this (if file is located in WEBROOT /MY_APP/Files)

$("#div1").load("/MY_APP/Files/demo_test.txt", function(responseText, statusText, xhr)

或完整路径

$("#div1").load("http://MyWebsite.com/MY_APP/Files/demo_test.txt", function(responseText, statusText, xhr)