dojo中的多部分表单数据ajax请求

时间:2013-01-22 13:24:36

标签: ajax dojo

我google了很多但是找不到办法为Multipart formdata enctype表单做ajax post请求。可以帮助任何人

1 个答案:

答案 0 :(得分:-1)

查看dojo.xhr文档中的示例1:http://dojotoolkit.org/reference-guide/1.8/dojo/xhr.html

经过调整/缩短的版本:

<form data-dojo-type="dijit/form/Form" id="myForm" data-dojo-id="myForm"
 encType="multipart/form-data" action="" method="">

 <input data-dojo-type="dijit/form/ValidationTextBox"
    type="text"
    id="name"
    name="name" />

 <div data-dojo-type="dijit/form/Button">
    Submit
    <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="evt">
        dojo.xhrPost({
            // The target URL on your webserver:
            url: "#",

            // The form node, which contains the
            // to be transferred form elements:
            form: "myForm",

            // Event handler on successful call:
            load: function(response, ioArgs){
                // do something
            }
        });
    </script>
 </div>
</form>