打开使用jQuery的一个图片文件夹 [英] Open a Image folder Using Jquery
本文介绍了打开使用jQuery的一个图片文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做我的mvc4项目。我有一个图片文件夹,我想打开和使用jquery列出文件夹中的所有图像。我写了下面的jQuery AJAX code为
I am doing my project in mvc4. I have an Image folder and I want to open and list all images in that folder using jquery . I write the following jquery ajax code for that
$(document).ready(function () {
var URL = '../../Content/Gallery/GalleryImages/DG/';
$.ajax({
url: URL,
success: function (data) {
$(data).find("a:contains(.jpg)").each(function () {
var images = $(this).attr("href");
alert(images);
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert("error");
}
});
});
但是,这总去错误的功能。谁能告诉我什么是确切的问题。是否有我的网址路径中的任何问题。
But this always go to Error function. Can anybody please tell me what is the exact problem. Is there any problem in my URL path.
推荐答案
您不能调用静态文件夹:
You cannot call a static folder:
var URL = '../../Content/Gallery/GalleryImages/DG/';
相反,你应该有一个控制器,它提供的图像
instead you should have a controller that serves images
这篇关于打开使用jQuery的一个图片文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文