English 中文(简体)
j 相当于XMLHttpRequest上载的钱?
原标题:jQuery equivalent to XMLHttpRequest s upload?
最佳回答

这里是我为解决这一问题而做的。 拨号为Jajax()的电话使XHR得以启动。 我在提出要求之前就提出,提出,然后提出结束,以便在需要时退款。 如果他们只是通过支取而来,就会变得更容易,但他们却不这样做。

var reader = new FileReader();

reader.onloadend = function (e) {
    var xhr, provider;

    xhr = jQuery.ajaxSettings.xhr();
    if (xhr.upload) {
        xhr.upload.addEventListener( progress , function (e) {
            // ...
        }, false);
    }   
    provider = function () {
        return xhr;
    };  

    // Leave only the actual base64 component of the  URL 
    // Sending as binary ends up mangling the data somehow
    // base64_decode() on the PHP side will return the valid file.
    var data = e.target.result;
    data = data.substr(data.indexOf( base64 ) + 7); 

    $.ajax({
        type:  POST ,
        url:  http://example.com/upload.php ,
        xhr: provider,
        dataType:  json ,
        success: function (data) {
            // ...
        },  
        error: function () {
            // ...
        },  
        data: {
            name: file.name,
            size: file.size,
            type: file.type,
            data: data,
        }   
    }); 
};  
reader.readAsDataURL(file);
问题回答

The documentation for the jqXHR (the superset of the XMLHttpRequest that is returned from jQuery s .ajax() call) does not describe the update feature as being exposed, which does not mean it isn t exposed. This question, though, seems to indicate that upload is not exposed. The answer provides a way to get to the native XMLHttpRequest object.

在j Query 1.5之前的版本中,XMLHttpRequest物体直接暴露,因此,你可以查阅浏览浏览器所支持的任何特征:

http://www.google.com/search?q=jquery+html+5+file+upload&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US: Official&client=firefox-a” rel=“nofollow noretinger”>jquery html 5 file upload ,该字标/使用超文本5文档APIC进行多份文档上载,但这一图形目前并未在IEC中运行。 如果你不希望使用超文本5,而现在确实希望得到交叉浏览器的支持,那么,在 j金矿场,你可以找到其他gin子。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签