javascript – jQuery表单插件

我试图上传并通过AJAX提交表单,我发现jQuery.form插件http://jquery.malsup.com/form/,这是我的代码:

     $("#submitSlide").click(function(){

         var options = { 
            success:    function(data) { 
                console.log(data); 
            },
            error : function( jqXHR , textStatus , errorThrown ){
               console.log( ' broked ' , jqXHR , textStatus , errorThrown );
           } ,
            dataType: 'html',
            type: 'POST',  
            url: 'http://www.slideshare.net/api/1/upload_slideshow'
        };

        $('#ssuploadform').ajaxSubmit(options);


         return false;
     });

但是我收到这样的错误:

    >>[jquery.form] Server abort: Error: Permission denied to access property 'document' (Error)
    >>[jquery.form] cannot access response document: Error: Permission denied to access property 'document'
    >>[jquery.form] aborting upload... aborted

你知道如何解决这个问题吗?

谢谢,我感谢任何帮助!

解决方法:

$.ajax()

Due to browser security restrictions, most “Ajax” requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.

你不能制作跨宗教的XHR.有关创意,请参阅How do I send a cross-domain POST request via JavaScript?.

上一篇:vue:v-on:submit.prevent


下一篇:javascript – 输入类型=“提交”按钮onClick:jQuery replaceWith阻止表单提交