【问题标题】:Ajax call with jquery-fileupload使用 jquery-fileupload 进行 Ajax 调用
【发布时间】:2012-11-28 12:24:04
【问题描述】:

在我的网站上加载 jquery-fileupload 时出现以下错误:

http://www.testsite.net/uploadfile/%5Bobject%20Object%5D?_=1354103435936

错误是(页面响应)

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>404 Not Found</title>
    </head><body>

<h1>Not Found</h1>    
<p>The requested URL was not found on this server.</p>

</body></html>

阅读 main.js 我发现这个调用有错误:

    // Load existing files:
    $.ajax({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: $('#fileupload').fileupload('option', 'url'),
        dataType: 'json',
        context: $('#fileupload')[0]
    }).done(function (result) {
        if (result && result.length) {
            $(this).fileupload('option', 'done')
                .call(this, null, {result: result});
        }
    });

【问题讨论】:

  • 错误在哪里?可以加吗?
  • 我已经更新了回复:-)
  • 嘿,你找到解决办法了吗?谢谢

标签: php jquery file-upload


【解决方案1】:

我通过在 $(document).ready() 中包含 main.js 来修复错误

以便 main.js 中的函数可以检测到

$(document).ready(function(){

  $.getScript('js/main.js');

  // make sure that the url in the main.js is correct
  // and if you still got errors, set timer
  // 
  // setTimeout(function(){
  //
  // 	$.getScript('js/main.js');
  // }, 1000);
  // 
  // after 1 second, the main.js will be included in the file

});

【讨论】:

    猜你喜欢
    • 2013-02-16
    • 2014-08-16
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多