XMLHttpRequest POST multipart/form-data

后端 未结 7 1590
清酒与你
清酒与你 2020-12-04 20:33

I want to use XMLHttpRequest in JavaScript to POST a form that includes a file type input element so that I can avoid page refresh and get useful XML back.

I can sub

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 20:48

    i am confuse about the onload event that you specified, it is on the page or on iframe?, the first answer is correct theres no way to do this using purely xmlhttprequest, if what you want to acheive is triggering some method once the response exist on iframe, simply check if it has content already or not using DOM scripting, then fire the method.

    to attach onload event to the iframe

    if(window.attachEvent){
     document.getElementById(iframe).attachEvent('onload', some_method);
    }else{
     document.getElementById(iframe).addEventListener('load', some_method, false);
    } 
    

提交回复
热议问题