问题描述
这是获取图像的脚本的一部分
This is the part of the script for getting the image
//Document.ready image load
$(document).ready(function () {
$.ajax({
dataType: "json",
url: "@Url.Action("FirstImage", "Home")",
success: function (jsonData) {
//Insert new image to the slide
newImg = $("<img />");
newImg.attr("data-id", jsonData.nextImage.id);
newImg.attr("data-catpos", jsonData.nextImage.categoryPosition);
newImg.attr("data-rateamount", jsonData.nextImage.amountOfRates);
newImg.attr("data-avg", jsonData.nextImage.rating);
newImg.attr("src", jsonData.nextImage.src);
newImg.attr("alt", "No image");
$(".slide").html(newImg);
console.log(jsonData.nextImage.src);
},
error: function () {
alert("Error getting next image");
}
});
});
这就是上面代码中的console.log所写的C:\ Users \ jim \ Dropbox \ egne projekter \ rateme \ rateme \ Content \ UploadedImages \ e630c24c-cb39-49a0-8356-7eb192d8f348.jpg
This is what the console.log in the code above writesC:\Users\jim\Dropbox\egne projekter\rateme\rateme\Content\UploadedImages\e630c24c-cb39-49a0-8356-7eb192d8f348.jpg
我怎么从chrome中得到以下异常?不允许加载本地资源
How come that i get the following exception from chrome?? Not allowed to load local resource
推荐答案
看起来您的应用程序正在通过文件系统路径(C:\ Users \ jim \ Dropbox \ egne projekter \ rateme \ rateme \ Content \ UploadedImages \ e630c24c-cb39-49a0-8356-7eb192d8f348.jpg). jQuery无法访问您的本地文件系统.我希望为您的资源启动一个http服务器,所以这些URL看起来像 http://127.0.0.1:1234/myApplication/Content/UploadedImages/e630c24c-cb39-49a0-8356-7eb192d8f348.jpg .希望能有所帮助.
It looks like your application is referencing your resources by a file system path (C:\Users\jim\Dropbox\egne projekter\rateme\rateme\Content\UploadedImages\e630c24c-cb39-49a0-8356-7eb192d8f348.jpg). Jquery doesn't have access to your local file system. I would like an http server is spun up for your resources, so the urls will look something like http://127.0.0.1:1234/myApplication/Content/UploadedImages/e630c24c-cb39-49a0-8356-7eb192d8f348.jpg. Hope can get a bit help.
这篇关于jQuery不允许加载本地资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!