两天来,我一直试图让 cfwheels 与 FineUploader 一起工作,但我只是不知道如何强制 jQuery 脚本执行控制器/动作。这是我到目前为止走了多远:
$(document).ready(function() {
var restricteduploader = new qq.FineUploader({
// Since we're using jQuery, use the jQuery way to select the HTML element
element: $('##restricted-fine-uploader')[0],
request: {
type: "POST",
url: $(this).attr("href") + "/index.cfm?controller=users&action=UploadFileXhr&format=json", // References "/say/hello?format=json"
dataType: "json",
endpoint: '/index.cfm?controller=users&action=UploadFileXhr&format=json'
},
multiple: false,
validation: {
allowedExtensions: ['jpeg', 'jpg', 'txt'],
sizeLimit: 5120000000 // 50 kB = 50 * 1024 bytes
},
text: {
uploadButton: 'Click or Drop'
},
showMessage: function(message) {
// Using Twitter Bootstrap's classes and jQuery selector and method
$('##restricted-fine-uploader').append('<div class="alert alert-error">' + message + '</div>');
},
debug: true
});
});
CFWheels 文档说我必须使用它来获取异步请求:
(function($){$(document).ready(function(){
// Listen to the "click" event of the "alert-button" link and make an AJAX request
$("#alert-button").click(function() {
$.ajax({
type: "POST",
url: $(this).attr("href") + "?format=json", // References "/say/hello?format=json"
dataType: "json",
success: function(response) {
$("h1").html(response.message);
$("p").html(response.time);
}
});
return false; // keeps the normal request from firing
});
});})(jQuery);
这三行是我试图合并到我的代码中的(因为这是我认为我需要的):
类型:“发布”,
url: $(this).attr("href") + "?format=json", // 引用 "/say/hello?format=json"
数据类型:“json”,
但是我尝试过的一切都没有奏效。我什至无法处理我的实际上传代码来让它工作,因为我什至无法让上传者启动所需的控制器/动作。
希望有人能够指出我正确的方向。谢谢!
问题也发布到 cfWheels 邮件列表:https ://groups.google.com/forum/?fromgroups=#!topic/cfwheels/UKk_57y9ncQ