[英]When I try to use ajax, chrome's console says “”Resource failed to load"
I want to download a javascript file using ajax. 我想使用ajax下载javascript文件。 But I can't do it.
但是我做不到。
Google chrome console says Resource failed to load
Google Chrome控制台表示
Resource failed to load
Here is my html. 这是我的HTML。 Please check it and give me comments.
请检查并给我评论。
https://www.box.com/s/b2mj0cs7xbdqh8sdrh92 https://www.box.com/s/b2mj0cs7xbdqh8sdrh92
Try doing GET
as your request type. 尝试将
GET
作为您的请求类型。 So your new code would read, 因此,您的新代码将显示为
$.ajax({
type: "GET",
url: "jquery.jsPlumb-1.3.16-all-min.js",
dataType: "script"
});
Also make sure that jquery.jsPlumb-1.3.16-all-min.js
exists in the same directory as index.htm
. 还要确保
jquery.jsPlumb-1.3.16-all-min.js
与index.htm
存在于同一目录中。 This still won't load it directly into the page, but would be able to access the text and then manipulate it however you want. 这仍然不会直接将其加载到页面中,但是可以访问文本,然后根据需要进行操作。
In my opionion, AJax shouldn't be used to download resource files, but rather to communicate with the server from the client. 在我看来,AJax不应用于下载资源文件,而应从客户端与服务器进行通信。 Too many implications in the former.
前者的含义太多。
What is your expected outcome with loading the js file? 加载js文件的预期结果是什么?
If you're really intending on doing this (and I wouldn't suggest it), use jQuery.getScript(): 如果您真的打算这样做(我不建议这样做),请使用jQuery.getScript():
http://api.jquery.com/jQuery.getScript/ http://api.jquery.com/jQuery.getScript/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.