用jquery-fileupload调用Ajax [英] Ajax call with jquery-fileupload

查看:176
本文介绍了用jquery-fileupload调用Ajax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

错误是(页面响应)

 <!DOCTYPE HTML PUBLIC -  // IETF // DTD HTML 2.0 // EN> 
< html>< head>
< title> 404未找到< / title>
< / head>< body>

< h1>未找到< / h1>
< p>在此服务器上找不到请求的网址。< / p>

< / body>< / html>

阅读main.js在这个调用中发现错误:

  //加载现有文件:
$ .ajax({
//取消注释以下内容以发送跨域cookie:
/ / 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});
}
});


解决方案

$(document).ready()



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

 


I have following error when load jquery-fileupload on my website:

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

error is (page response)

<!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>

reading main.js I found error in this call:

    // 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});
        }
    });

解决方案

i fixed the error by including the main.js on $(document).ready()

so that functions in main.js can detect the

$(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

});

这篇关于用jquery-fileupload调用Ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆